From b05b5b3915d9fe0d46564776527babe91da628dd Mon Sep 17 00:00:00 2001 From: annrra Date: Tue, 27 Aug 2024 23:12:07 +0300 Subject: [PATCH 1/3] [PROD-7859] Handle caret positioning when inserting emojis --- .../js/buddypress-activity-post-form.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js index 81641696c4..fde621ff55 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js @@ -5085,9 +5085,28 @@ window.bp = window.bp || {}; emojibtn_click: function () { $( '#whats-new' )[0].emojioneArea.hidePicker(); if ( window.getSelection && document.createRange ) { //Get caret position when user adds emoji - var sel = window.getSelection && window.getSelection(); + var sel = window.getSelection(); if ( sel && sel.rangeCount > 0 ) { - window.activityCaretPosition = sel.getRangeAt( 0 ); + var range = sel.getRangeAt( 0 ); + + // Check if range is in the parent div container instead of a child node + if ( range.commonAncestorContainer === $( '#whats-new' )[0] ) { + // Set caret in the nearest text node or valid element + var childNodes = $( '#whats-new' )[0].childNodes; + + // Position the caret within the first text node/element + if ( childNodes.length > 0 ) { + for ( var i = 0; i < childNodes.length; i++ ) { + if ( childNodes[i].nodeType === Node.TEXT_NODE || childNodes[i].nodeType === Node.ELEMENT_NODE ) { + range.setStart( childNodes[i], 0 ); + range.setEnd( childNodes[i], 0 ); + break; + } + } + } + } + + window.activityCaretPosition = range; } } else { window.activityCaretPosition = document.selection.createRange(); From 42eaf1244d20ffc16c054593ed0406eb2c713ef4 Mon Sep 17 00:00:00 2001 From: annrra Date: Wed, 28 Aug 2024 22:15:15 +0300 Subject: [PATCH 2/3] [PROD-7859] Move caret after inserted emoji --- .../bp-nouveau/js/buddypress-activity-post-form.js | 6 ++++++ .../bp-nouveau/js/buddypress-activity-post-form.min.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js index fde621ff55..7560ecf092 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js @@ -5105,6 +5105,12 @@ window.bp = window.bp || {}; } } } + + // Move caret after the inserted emoji + sel.removeAllRanges(); + range.setStart(range.endContainer, range.endOffset); + range.setEnd(range.endContainer, range.endOffset); + sel.addRange(range); window.activityCaretPosition = range; } diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js index abd2af60cb..d21540f0a2 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js @@ -1 +1 @@ -window.wp=window.wp||{},window.bp=window.bp||{},function(w){bp.Nouveau=bp.Nouveau||{},void 0!==bp.Nouveau.Activity&&"undefined"!=typeof BP_Nouveau&&(_.extend(bp,_.pick(wp,"Backbone","ajax","template")),bp.Models=bp.Models||{},bp.Collections=bp.Collections||{},bp.Views=bp.Views||{},bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",bp.draft_ajax_request=null,bp.old_draft_data=!1,bp.draft_activity={object:!1,data_key:!1,data:!1,post_action:"update",allow_delete_media:!1,display_post:""},bp.draft_local_interval=!1,bp.draft_ajax_interval=!1,bp.draft_content_changed=!1,bp.Nouveau.Activity.postForm={start:function(){this.views=new Backbone.Collection,this.ActivityObjects=new bp.Collections.ActivityObjects,this.buttons=new Backbone.Collection,_.isUndefined(window.Dropzone)||_.isUndefined(BP_Nouveau.media)||this.dropzoneView(),this.postFormView(),this.postFormPlaceholderView(),this.getCurrentDraftActivity(),this.syncDraftActivity(),this.reloadWindow()},postFormView:function(){var e;this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),w("#bp-nouveau-activity-form").length&&(this.postForm=new bp.Views.PostForm,this.views.add({id:"post_form",view:this.postForm}),this.postForm.inject("#bp-nouveau-activity-form"),w(".activity-update-form #user-status-huddle, .activity-update-form #whats-new-content, .activity-update-form #whats-new-attachments").wrapAll('
'),e=this,w(document).on("click",".activity-update-form.modal-popup:not(.bp-activity-edit) .activity-update-form-overlay",function(){e.postForm.$el.hasClass("bp-activity-edit")||(bp.Nouveau.Activity.postForm.clearDraftInterval(),bp.Nouveau.Activity.postForm.collectDraftActivity(),bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)),setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)}),Backbone.trigger("mediaprivacy"))},postFormPlaceholderView:function(){w("#bp-nouveau-activity-form-placeholder").length&&(this.postFormPlaceholder=new bp.Views.PostFormPlaceholder,this.views.add({id:"post_form_placeholder",view:this.postFormPlaceholder}),this.postFormPlaceholder.inject("#bp-nouveau-activity-form-placeholder"),w(".activity-form-placeholder #user-status-huddle, .activity-form-placeholder #whats-new-content-placeholder").wrapAll('
'))},dropzoneView:function(){this.dropzone=null,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:_.isUndefined(BP_Nouveau.media.maxFiles)?10:BP_Nouveau.media.maxFiles,maxFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size},_.isUndefined(BP_Nouveau.media.dropzone_options)||Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options)},displayEditActivity:function(t,i){bp.draft_activity.allow_delete_media=!0,bp.draft_activity.display_post="edit";var e=this;e.postForm.$el.trigger("reset"),e.editActivityData=t,this.model.set("edit_activity",!0),e.postForm.$el.addClass("bp-activity-edit").addClass("loading"),e.postForm.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),e.postForm.$el.removeClass("bp-hide"),e.postForm.$el.find("#whats-new-toolbar").addClass("hidden"),setTimeout(function(){var e=new Event("bp_activity_edit");bp.Nouveau.Activity.postForm.displayEditDraftActivityData(t,e,i)},0)},displayEditActivityForm:function(e,t){var i=w("#bp-nouveau-activity-form"),a=w("#bp-nouveau-activity-form-placeholder"),o=w("#bp-nouveau-single-activity-edit-form-wrap");o.length&&o.show(),bp.privacyEditable=e.can_edit_privacy,bp.album_id=e.album_id,bp.folder_id=e.folder_id,bp.group_id=e.group_id,bp.privacy=e.privacy,this.displayEditActivity(e,t),this.model.set("edit_activity",!0);e=w("#whats-new")[0],t=w("#whats-new-content")[0];window.activity_edit_editor=new window.MediumEditor(e,{placeholder:{text:"",hideOnClick:!0},toolbar:{buttons:["bold","italic","unorderedlist","orderedlist","quote","anchor","pre"],relativeContainer:t,static:!0,updateOnEmptySelection:!0},imageDragging:!1,anchor:{linkValidation:!0}}),window.activity_edit_editor.subscribe("editablePaste",function(t){setTimeout(function(){var e=w(t.target).find("li").filter(function(){return!w(this).parent().is("ul")&&!w(this).parent().is("ol")});0")},0)}),i.addClass("modal-popup").closest("body").addClass("activity-modal-open"),a.show(),setTimeout(function(){w("#whats-new img.emoji").each(function(e,t){w(t).addClass("emojioneemoji");var i=w(t).attr("alt");w(t).attr("data-emoji-char",i),w(t).removeClass("emoji")})},10),this.activityEditHideModalEvent()},activityEditHideModalEvent:function(){var e=this;w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&w(".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset").trigger("click")}),w(document).on("click",".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset",function(){e.postActivityEditHideModal()})},postActivityEditHideModal:function(){bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",w(".activity-update-form.modal-popup").removeClass("modal-popup group-activity").closest("body").removeClass("activity-modal-open");var e=w("#bp-nouveau-activity-form-placeholder"),t=w("#bp-nouveau-single-activity-edit-form-wrap"),i=w("#bp-nouveau-activity-form");w("#whats-new-content").parent().is(".edit-activity-content-wrap")&&w("#whats-new-content").unwrap(),e.hide(),t.length&&t.hide(),i.hasClass("is-bp-hide")&&i.addClass("bp-hide"),bp.Views.ActivityHeader.prototype.resetMultiMediaOptions()},createThumbnailFromUrl:function(t){var i=this;i.dropzone.createThumbnailFromUrl(t,i.dropzone.options.thumbnailWidth,i.dropzone.options.thumbnailHeight,i.dropzone.options.thumbnailMethod,!0,function(e){i.dropzone.emit("thumbnail",t,e),i.dropzone.emit("complete",t)})},displayEditDraftActivityData:function(e,t,i){var a=this;a.postForm.$el.parent("#bp-nouveau-activity-form").removeClass("bp-hide"),a.postForm.$el.find("#whats-new").html(e.content),null!=i&&a.postForm.$el.find("#whats-new").data("activity-url-preview",i);var o,s=a.postForm.$el.find("#whats-new").get(0);s.focus(),0')),bp.privacyEditable||"groups"===e.object?a.postForm.$el.removeClass("bp-activity-edit--privacy-idle"):a.postForm.$el.addClass("bp-activity-edit--privacy-idle"),0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");e.postForm.model.set("content",i,{silent:!0}),e.postForm.model.set(t,{silent:!0});var a=e.postForm.model.get("media");if("group"===e.postForm.model.get("object")&&!_.isUndefined(a)&&a.length){for(var o=0;o"+BP_Nouveau.media.invalid_media_type+". "+t.data.feedback+""),this.removeFile(e);bp.draft_content_changed=!0}),bp.Nouveau.Activity.postForm.dropzone.on("error",function(e,t){e.accepted?_.isUndefined(t)||_.isUndefined(t.data)||_.isUndefined(t.data.feedback)?"error"==e.status&&e.xhr&&0==e.xhr.status&&w(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):w(e.previewElement).find(".dz-error-message span").text(t.data.feedback):(Backbone.trigger("onError","
"+BP_Nouveau.media.invalid_media_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.media.length){for(var t in l.media){var i;e.id===l.media[t].id?(_.isUndefined(l.media[t].saved)||l.media[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.media.splice(t,1),l.model.set("media",l.media)):"edit"===bp.draft_activity.display_post||!e.media_edit_data||(i=e.media_edit_data.id)===l.media[t].id&&(l.media.splice(t,1),l.model.set("media",l.media),bp.Nouveau.Media.removeAttachment(i))}var a=l.$el.find(".dz-preview.dz-error").length;l.media.length===a&&l.model.unset("media")}_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("no-click"),l.model.unset("media"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0"+BP_Nouveau.media.invalid_file_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.document.length)for(var t in l.document){var i;e.id===l.document[t].id?(_.isUndefined(l.document[t].saved)||l.document[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.document.splice(t,1),l.model.set("document",l.document)):"edit"===bp.draft_activity.display_post||!e.document_edit_data||(i=e.document_edit_data.id)===l.document[t].id&&(l.document.splice(t,1),l.model.set("document",l.document),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),l.model.unset("document"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(e){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0'),w(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),bp.Nouveau.Activity.postForm.dropzone.on("sending",function(e,t,i){i.append("action","video_upload"),i.append("_wpnonce",BP_Nouveau.nonces.video);i=l.$el.parents("#whats-new-form");i.find("#activity-media-button")&&i.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-gif-button")&&i.find("#activity-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-document-button")&&i.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-video-button")&&i.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("no-click")}),bp.Nouveau.Activity.postForm.dropzone.on("uploadprogress",function(e){l.$el.closest("#whats-new-form").addClass("media-uploading");var t=w(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i;var a=i-e.upload.progress.toFixed(0)/100*i;e.upload.progress<=99?(w(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,w(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),bp.Nouveau.Activity.postForm.dropzone.on("success",function(e,t){if(100===e.upload.progress&&(w(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,w(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),w(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,s,d,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),d=[],a=0,o=(s=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a"+BP_Nouveau.video.invalid_video_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.video.length)for(var t in l.video){var i;e.id===l.video[t].id?(_.isUndefined(l.video[t].saved)||l.video[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.video.splice(t,1),l.model.set("video",l.video)):"edit"===bp.draft_activity.display_post||!e.video_edit_data||(i=e.video_edit_data.id)===l.video[t].id&&(l.video.splice(t,1),l.model.set("video",l.video),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),l.model.unset("video"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),""!==a.find(".ac-textarea").children(".ac-input").text().trim()||0<=i.indexOf("emojioneemoji")?w(a).closest("form").addClass("has-content"):w(a).closest("form").removeClass("has-content")),_.isUndefined(e)||_.isEmpty(t)||!_.isEmpty(this.model.get("gif_data"))||(bp.draft_content_changed=!0)}}),bp.Views.GifMediaSearchDropdown=bp.View.extend({tagName:"div",className:"activity-attached-gif-container",template:bp.template("gif-media-search-dropdown"),total_count:0,offset:0,limit:20,q:null,requests:[],standalone:!1,events:{"keydown .search-query-input":"search","click .found-media-item":"select"},initialize:function(e){this.select=this.select.bind(this),e&&void 0!==e.standalone&&(this.standalone=e.standalone),this.options=e||{},this.giphy=new window.Giphy(BP_Nouveau.media.gif_api_key),this.gifDataItems=new bp.Collections.GifDatas,this.listenTo(this.gifDataItems,"add",this.addOne),this.listenTo(this.gifDataItems,"reset",this.addAll),document.addEventListener("scroll",_.bind(this.loadMore,this),!0)},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.$gifResultItem=this.$el.find(".gif-search-results-list"),this.loadTrending(),this},search:function(e){if("Enter"===e.key||13===e.keyCode)return e.preventDefault(),!1;var t=this;null!=this.Timeout&&clearTimeout(this.Timeout),""!==e.target.value?this.Timeout=setTimeout(function(){this.Timeout=null,t.searchGif(e.target.value)},1e3):this.loadTrending()},searchGif:function(e){var t=this;t.q=e,t.offset=0,t.clearRequests(),t.el.classList.add("loading"),this.$el.find(".gif-no-results").removeClass("show"),this.$el.find(".gif-no-connection").removeClass("show");e=t.giphy.search({q:e,offset:t.offset,fmt:"json",limit:this.limit},function(e){void 0!==e.data.length&&0===e.data.length&&w(t.el).find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&w(t.el).find(".gif-no-connection").addClass("show"),t.gifDataItems.reset(e.data),t.total_count=e.pagination.total_count,t.el.classList.remove("loading")},function(){w(t.el).find(".gif-no-connection").addClass("show")});t.requests.push(e),t.offset=t.offset+t.limit},select:function(e){e.preventDefault(),this.$el.parent().removeClass("open");var t=this.gifDataItems.findWhere({id:e.currentTarget.dataset.id});this.model.set("gif_data",t.attributes);t=this.$el.parents("#whats-new-form");t.find("#activity-document-button")&&t.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-media-button")&&t.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-video-button")&&t.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.parents(".ac-reply-content");t.find(".ac-reply-toolbar .ac-reply-media-button")&&t.find(".ac-reply-toolbar .ac-reply-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-document-button")&&t.find(".ac-reply-toolbar .ac-reply-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-video-button")&&t.find(".ac-reply-toolbar .ac-reply-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.closest("#whats-new-form");(this.standalone?this.$el.closest(".screen-content, .elementor-widget-container, .buddypress-wrap").find("#activity-modal .ac-form"):this.$el.closest(".ac-form")).addClass("has-gif");t=t.find(".whats-new-scroll-view");0=i.scrollHeight&&!i.classList.contains("loading")&&0/g,""):e).indexOf("http://")?i=this.getURL("http://",e):0<=e.indexOf("https://")?i=this.getURL("https://",e):0<=e.indexOf("www.")&&(i=this.getURL("www",e)),""!==i&&((e=document.createElement("a")).href=i,e=e.hostname,-1!==BP_Nouveau.activity.params.excluded_hosts.indexOf(e)&&(i="")),""!==i?this.loadURLPreview(i):void 0!==a&&this.loadURLPreview(a))},getURL:function(e,t){var i="",a=(t=t.replace(/ /g,"")).indexOf(e),o="";if(_.isUndefined(w(w.parseHTML(t)).attr("href"))){for(var s=a;s"===t[s+1]||"<"===t[s]&&"b"===t[s+1]&&"r"===t[s+2]);s++)i+=t[s];"www"===e&&(i=(e="http://")+i)}else i=w(t).attr("href");e=document.createElement("div");e.innerHTML=i;for(var d=e.getElementsByTagName("*");d[0];)d[0].parentNode.removeChild(d[0]);return o=0")},0)}))}),w(document).on("keyup",".activity-form .medium-editor-toolbar-input",function(e){var t=e.target.value;bp.Nouveau.isURL(t)?w(e.target).removeClass("isNotValid").addClass("isValid"):w(e.target).removeClass("isValid").addClass("isNotValid")}),e=bp.Nouveau.getLinkParams(null,"r")||null,_.isNull(e)||w("#message_content").focus())}}),bp.Views.WhatsNewPostIn=bp.View.extend({tagName:"select",id:"whats-new-post-in",attributes:{name:"whats-new-post-in","aria-label":BP_Nouveau.activity.strings.whatsnewpostinLabel},events:{change:"change"},keys:[],initialize:function(){this.model=new Backbone.Model,this.filters=this.options.filters||{},this.$el.html(_.chain(this.filters).map(function(e,t){return{el:w("").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())},change:function(){var e=this.filters[this.el.value];e&&this.model.set({selected:this.el.value,placeholder:e.autocomplete_placeholder})}}),bp.Views.ActivityPrivacy=bp.View.extend({tagName:"div",id:"activity-post-form-privacy",template:bp.template("activity-post-form-privacy"),initialize:function(){this.model=new bp.Models.Activity}}),bp.Views.Item=bp.View.extend({tagName:"div",className:"bp-activity-object",template:bp.template("activity-target-item"),initialize:function(){this.model.get("selected")&&(this.el.className+=" selected")},events:{click:"setObject"},setObject:function(e){e.preventDefault();e=w("#whats-new-form");!0===this.model.get("selected")&&this.model.unset("selected"),e.removeClass("focus-in--blank-group");var t=this;t.model.hasOwnProperty("attributes")&&t.model.attributes.hasOwnProperty("object_type")&&"group"===t.model.attributes.object_type&&((i=_.find(this.model.collection.models,function(e){return e!==t.model&&e.get("selected")}))&&i.set("selected",!1)),this.model.set("selected",!0);var i=this.model.attributes;void 0!==i.group_media&&!1===i.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),void 0!==i.group_document&&!1===i.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),void 0!==i.group_video&&!1===i.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide")}}),bp.Views.AutoComplete=bp.View.extend({tagName:"div",id:"whats-new-post-in-box-items",ac_req:!1,events:{keyup:"autoComplete"},initialize:function(){var e,t,i,a,o=new bp.Views.ActivityInput({type:"text",id:"activity-autocomplete",placeholder:this.options.placeholder||""}).render();this.$el.html(o.$el),o.$el.wrapAll('').after(''),this.$el.append('
'),this.on("ready",this.setFocus,this),"group"===this.options.type&&((o=BP_Nouveau.activity.params.objects.group_list)&&(this.collection.add(o),_.each(this.collection.models,function(e){this.addItemView(e)},this)),e=BP_Nouveau.activity.params.objects.group_total_page,o=BP_Nouveau.activity.params.objects.group_count,1this.collection.models.length&&((t=this).$el.find("#bp-activity-group-ac-items").addClass("group_scrolling load_more_data"),i=this.$el.find("#bp-activity-group-ac-items"),a=1,i.on("scroll",function(){if(window.acScrollPosition=i.scrollTop(),t.$el.find("#bp-activity-group-ac-items").hasClass("load_more_data")){if(e<++a)return t.$el.find("#bp-activity-group-ac-items").removeClass("load_more_data"),!(a=1);t.loadMoreData(t,a)}}))),this.collection.on("add",this.addItemView,this),this.collection.on("reset",this.cleanView,this)},setFocus:function(){var e;this.$el.find("#activity-autocomplete").focus(),w("#bp-activity-group-ac-items .bp-activity-object").length&&(e=w("#bp-activity-group-ac-items"),w(".bp-activity-object").each(function(){w(this).hasClass("selected")&&(e.scrollTop(window.acScrollPosition),e.on("scroll",function(){window.acScrollPosition=w(this).scrollTop()}))}))},addItemView:function(e){e=new bp.Views.Item({model:e});this.$el.find("#bp-activity-group-ac-items").append(e.render().$el)},autoComplete:function(){var e=this,t=w("#activity-autocomplete").val(),i=e.$el.closest("#whats-new-form");0===parseInt(t.length)?(this.autoCompleteCollectionData(e,t),e.$el.find("#bp-activity-group-ac-items").addClass("load_more_data"),e.$el.removeClass("activity-is-autocomplete"),i.addClass("focus-in--blank-group")):(e.$el.addClass("activity-is-autocomplete"),w("#whats-new-post-in-box-items .activity-autocomplete-clear").on("click",function(){w("#activity-autocomplete").val("").keyup(),i.addClass("focus-in--blank-group")})),t.length<2||this.autoCompleteCollectionData(e,t)},autoCompleteCollectionData:function(e,t){this.collection.reset(),this.ac_req&&this.ac_req.abort(),"group"===this.options.type?(this.$el.find("#bp-activity-group-ac-items").html('
'+BP_Nouveau.activity.params.objects.group.finding_group_placeholder+"
"),this.$el.find("#bp-activity-group-ac-items").addClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").html('');var i={type:this.options.type,nonce:BP_Nouveau.nonces.activity};""!==t&&(i.search=t),this.ac_req=this.collection.fetch({data:i,success:_.bind(this.itemFetched,this,e.options.type),error:_.bind(this.itemFetched,this,e.options.type)})},itemFetched:function(e,t){t.length||this.cleanView(e),"group"===e?(this.$el.find("#bp-activity-group-ac-items").find(".groups-selection--finding").remove(),this.$el.find("#bp-activity-group-ac-items").removeClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").find("i.dashicons").remove()},cleanView:function(e){"group"===e?this.$el.find("#bp-activity-group-ac-items").html(''+BP_Nouveau.activity.params.objects.group.no_groups_found+""):this.$el.find("#bp-activity-group-ac-items").html(""),_.each(this.views._views[""],function(e){e.remove()})},loadMoreData:function(i,e){this.$el.find("#bp-activity-group-ac-items .groups-selection--loading").length||this.$el.find("#bp-activity-group-ac-items .bp-activity-object:last").after('
'+BP_Nouveau.activity.params.objects.group.loading_group_placeholder+"
");var a=!1;return(new bp.Collections.fetchCollection).fetch({type:"POST",data:{type:i.options.type,nonce:BP_Nouveau.nonces.activity,page:e,action:"bp_nouveau_get_activity_objects"},success:function(e,t){!0===t.success&&(i.collection.add(t.data),w("#bp-activity-group-ac-items .groups-selection--loading").remove(),a=!0)}}),a}}),bp.Views.UserStatusHuddle=bp.View.extend({tagName:"div",id:"user-status-huddle",className:"bp-activity-huddle",initialize:function(){this.views.add(new bp.Views.CaseAvatar({model:this.model})),this.views.add(new bp.Views.CaseHeading({model:this.model})),this.views.add(new bp.Views.CasePrivacy({model:this.model})),void 0!==bp.Views.PostScheduleTime&&this.views.add(new bp.Views.PostScheduleTime({model:this.model})),w("#whats-new-heading, #whats-new-status").wrapAll('
'),setTimeout(function(){w(".activity-singular #whats-new-heading, .activity-singular #whats-new-status, .activity-singular #activity-schedule-section").wrapAll('
')},1e3)}}),bp.Views.CaseAvatar=bp.View.extend({tagName:"div",id:"whats-new-avatar",template:bp.template("activity-post-case-avatar"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CaseHeading=bp.View.extend({tagName:"div",id:"whats-new-heading",template:bp.template("activity-post-case-heading"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CasePrivacy=bp.View.extend({tagName:"div",id:"whats-new-status",template:bp.template("activity-post-case-privacy"),events:{"click #bp-activity-privacy-point":"privacyTarget"},initialize:function(){this.listenTo(Backbone,"privacy:updatestatus",this.updateStatus),this.model.on("change:privacy",this.render,this)},render:function(){var e;return this.$el.html(this.template(this.model.toJSON())),_.isUndefined(BP_Nouveau.activity.params.object)||"group"!==BP_Nouveau.activity.params.object||"group"!==BP_Nouveau.activity.params.object||(this.model.set("item_name",BP_Nouveau.activity.params.item_name),this.model.set("privacy","group"),e=BP_Nouveau.activity.params.item_name,w("#whats-new-form").find(".bp-activity-privacy-status").text(e),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),BP_Nouveau.activity.params.group_avatar&&!1===BP_Nouveau.activity.params.group_avatar.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),bp.draft_activity.data.item_id=BP_Nouveau.activity.params.item_id,bp.draft_activity.data.group_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.group_image=BP_Nouveau.activity.params.group_avatar,bp.draft_activity.data.item_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.privacy="group",bp.draft_activity.data["group-privacy"]="bp-item-opt-"+BP_Nouveau.activity.params.item_id,localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity))),!_.isUndefined(bp.draft_activity)&&""!==bp.draft_activity.object&&"group"===bp.draft_activity.object&&bp.draft_activity.data&&""!==bp.draft_activity.data&&(this.model.set("item_name",bp.draft_activity.data.item_name),this.model.set("privacy","group"),w("#whats-new-form").find(".bp-activity-privacy-status").text(bp.draft_activity.data.item_name),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),bp.draft_activity.data.group_image&&!1===bp.draft_activity.data.group_image.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"))),this},updateStatus:function(){this.model.get("privacy")},privacyTarget:function(e){if(this.$el.find("#bp-activity-privacy-point").hasClass("bp-activity-edit-group")||!_.isUndefined(BP_Nouveau.activity.params.object)&&"group"===BP_Nouveau.activity.params.object||!bp.privacyEditable)return!1;e.preventDefault(),w("#activity-post-form-privacy").show(),w("#whats-new-form").addClass("focus-in--privacy"),Backbone.trigger("privacy:headerupdate"),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.closest("#whats-new-form").find(".bp-activity-privacy__input:checked").val())}}),bp.Views.PrivacyStage=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage",className:"bp-activity-privacy-stage",events:{"click #privacy-status-submit":"privacyStatusSubmit","click #privacy-status-back":"backPrivacySelector","click #privacy-status-group-back":"backGroupSelector","click input.bp-activity-privacy__input":"privacySelector"},initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.PrivacyStageBody({model:this.model}),this.views.add(e)),this.views.add(new bp.Views.PrivacyStageFooter({model:this.model}))},privacyStatusSubmit:function(e){e.preventDefault();var t=this.$el.find(".bp-activity-privacy__input:checked").val();this.model.set("privacy",t),this.model.set("privacy_modal","general"),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}));var i=w("#whats-new-form");i.removeClass("focus-in--privacy focus-in--group"),Backbone.trigger("privacy:updatestatus");var a,e=this.model.attributes.item_id;"group"===t?(a=i.find("#bp-item-opt-"+e).data("title"),i.find(".bp-activity-privacy-status").text(a),i.find("#bp-activity-privacy-point").removeClass().addClass(t),this.model.set("item_name",a),this.model.set("group_name",a),this.model.attributes.group_image&&!1===this.model.attributes.group_image.includes("mystery-group")?(i.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon"),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").html('')):(i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model})),a=i.find("#bp-item-opt-"+e).data("allow-schedule-post"),_.isUndefined(a)||"enabled"!==a?"scheduled"===this.model.attributes.activity_action_type?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide"),Backbone.trigger("onError",BP_Nouveau.activity_schedule.strings.notAllowScheduleWarning,"error")):(this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):(this.model.set("schedule_allowed",a),i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"))):(_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"),e=this.model.attributes.privacy,a=i.find("#"+e).data("title"),i.find("#bp-activity-privacy-point").removeClass().addClass(e),i.find(".bp-activity-privacy-status").text(a),i.find(".bp-activity-privacy__input#"+e).prop("checked",!0),i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"),this.model.set("item_id",0),this.model.set("item_name",""),this.model.set("group_name",""),this.model.set("group_image",""),this.model.set("group-privacy",""),bp.draft_activity.data.item_id=0,bp.draft_activity.data.group_name="",bp.draft_activity.data.group_image="",bp.draft_activity.data.item_name="",bp.draft_activity.data.privacy=e,bp.draft_activity.data["group-privacy"]="",localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity)))},backPrivacySelector:function(e){e.preventDefault();e=this.model.get("privacy");w("#whats-new-form").removeClass("focus-in--privacy focus-in--group"),this.model.set("privacy_modal","general"),this.$el.find("input#"+e).prop("checked",!0),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.find(".bp-activity-privacy__input:checked").val())},backGroupSelector:function(e){e.preventDefault();var t=w("#whats-new-form");this.model.set("privacy_modal","profile"),t.removeClass("focus-in--group");e=this.model.get("privacy");this.$el.find("input#"+e).prop("checked",!0),w("#activity-post-form-privacy").show(),t.removeClass("focus-in--blank-group")},privacySelector:function(e){var t=w("#whats-new-form");"group"===w(e.currentTarget).val()?(w(e.currentTarget).closest("#whats-new-privacy-stage").find("#whats-new-post-in").val("group").trigger("change"),t.addClass("focus-in--group"),this.model.set("privacy_modal","group"),this.model.set("object",w(e.currentTarget).val()),w("#activity-post-form-privacy").hide(),0===this.model.attributes.item_id&&t.addClass("focus-in--blank-group")):(w("#privacy-status-submit").click(),this.model.set("object","user"),Backbone.trigger("mediaprivacytoolbar"))}}),bp.Views.PrivacyStageBody=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-body",className:"privacy-status-form-body",initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.ActivityPrivacy({model:this.model}),this.views.add(e)),_.isUndefined(BP_Nouveau.activity.params.objects)&&"user"===BP_Nouveau.activity.params.object&&this.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length&&(!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData))?this.views.add(new bp.Views.FormTarget({model:this.model})):!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData)||this.views.add(new bp.Views.EditActivityPostIn({model:this.model}))}}),bp.Views.PrivacyStageFooter=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-footer",className:"privacy-status-form-footer",template:bp.template("activity-post-privacy-stage-footer")}),bp.Views.FormContent=bp.View.extend({tagName:"div",id:"whats-new-content",events:{"click .medium-editor-toolbar-actions":"focusEditor","input #whats-new":"focusEditorOnChange","click .medium-editor-toolbar li.close-btn":"hideToolbarSelector"},initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea")),this.$el.append(''),this.views.set("#whats-new-textarea",new bp.Views.WhatsNew({activity:this.options.activity}))},hideToolbarSelector:function(e){e.preventDefault(),w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar").removeClass("active")},focusEditor:function(e){null===window.activity_editor.exportSelection()&&w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus(),e.preventDefault()},focusEditorOnChange:function(e){var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");setTimeout(function(){t.addClass("medium-editor-toolbar-active"),w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus()},0)}}),bp.Views.FormOptions=bp.View.extend({tagName:"div",id:"whats-new-options",template:bp.template("activity-post-form-options")}),bp.Views.FormTarget=bp.View.extend({tagName:"div",id:"whats-new-post-in-box",className:"in-profile",initialize:function(){var e=new bp.Views.WhatsNewPostIn({filters:BP_Nouveau.activity.params.objects});this.views.add(e),e.model.on("change",this.attachAutocomplete,this),bp.Nouveau.Activity.postForm.ActivityObjects.on("change:selected",this.postIn,this),this.toggleMultiMediaOptions()},attachAutocomplete:function(e){0!==bp.Nouveau.Activity.postForm.ActivityObjects.models.length&&bp.Nouveau.Activity.postForm.ActivityObjects.reset(),_.each(this.views._views[""],function(e){_.isUndefined(e.collection)||e.remove()}),"profile"!==e.get("selected")?(this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:e.get("selected"),placeholder:e.get("placeholder")})),this.model.set("object",e.get("selected"))):this.model.set({object:"user",item_id:0}),this.updateDisplay(),this.toggleMultiMediaOptions()},postIn:function(e){if(_.isUndefined(e.get("id")))return this.model.set("item_id",0),void this.attachAutocomplete(new Backbone.Model({selected:this.model.get("object")}));this.model.set("item_id",e.get("id")),"group"===this.model.get("object")?(this.views.remove("#whats-new-post-in-box-items"),this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:this.model.get("object"),placeholder:BP_Nouveau.activity.params.objects.group.autocomplete_placeholder})),this.model.set("object",this.model.get("object")),this.model.set("group_name",e.get("name")),this.model.set("item_name",e.get("name")),this.model.set("group_image",e.get("avatar_url")),this.model.set("group_url",e.get("group_url"))):this.views.set("#whats-new-post-in-box-items",new bp.Views.Item({model:e}))},updateDisplay:function(){"user"!==this.model.get("object")?(this.$el.removeClass(),w("#activity-post-form-privacy").hide()):this.$el.hasClass("in-profile")||(this.$el.addClass("in-profile"),w("#activity-post-form-privacy").show())},toggleMultiMediaOptions:function(){_.isUndefined(BP_Nouveau.media)||("user"!==this.model.get("object")?(!1===BP_Nouveau.media.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model}),!1===BP_Nouveau.media.emoji.groups?(w("#whats-new-textarea").find("img.emojioneemoji").remove(),w("#editor-toolbar .post-emoji").addClass("post-emoji-hide")):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")):(!1===BP_Nouveau.media.profile_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.profile_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.profile_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}),!1===BP_Nouveau.media.emoji.profile?(w("#editor-toolbar .post-emoji").addClass("post-emoji-hide"),w("#whats-new-textarea").find("img.emojioneemoji").remove()):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")),w(".medium-editor-toolbar").removeClass("active medium-editor-toolbar-active"),w("#show-toolbar-button").removeClass("active"),w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip",w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip-show")))}}),bp.Views.EditorToolbar=bp.View.extend({tagName:"div",id:"editor-toolbar",template:bp.template("editor-toolbar"),events:{"click .show-toolbar":"toggleToolbarSelector","click .post-mention":"triggerMention"},toggleToolbarSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");t.hasClass("active")||bp.Nouveau.mediumEditorButtonsWarp(t),w(e.currentTarget).find(".toolbar-button").toggleClass("active"),w(e.currentTarget).find(".toolbar-button").hasClass("active")?(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-hide")),null!=window.activity_editor.exportSelection()&&t.addClass("medium-editor-toolbar-active")):(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-show")),null===window.activity_editor.exportSelection()&&t.removeClass("medium-editor-toolbar-active"),t.find("li.medium-editor-action-more").removeClass("active")),w(window.activity_editor.elements[0]).focus(),t.toggleClass("medium-editor-toolbar-active active")},triggerMention:function(e){e.preventDefault();var a=this.$el,o=a.closest(".activity-update-form").find("#whats-new"),s=a.closest(".whats-new-scroll-view").scrollTop();setTimeout(function(){var e;o.focus(),window.activityCaretPosition&&(window.getSelection&&document.createRange?((t=document.createRange()).setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),t.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),(e=window.getSelection()).removeAllRanges(),e.addRange(t)):((i=document.body.createTextRange()).moveToElementText(o[0]),i.setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),i.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),i.select()));var t=window.getSelection().getRangeAt(0).cloneRange();t.collapse(!0),t.setStart(o[0],0);var i=t.toString().slice(-1);w(t.endContainer.parentElement).hasClass("atwho-inserted")||(""===i.trim()?document.execCommand("insertText",!1,"@"):"@"!==i&&document.execCommand("insertText",!1," @")),o.trigger("keyup"),setTimeout(function(){o.trigger("keyup"),a.closest(".whats-new-scroll-view").scrollTop(s)},0)},0)}}),bp.Views.ActivityToolbar=bp.View.extend({tagName:"div",id:"whats-new-toolbar",template:bp.template("whats-new-toolbar"),events:{"click .post-elements-buttons-item.disable .toolbar-button":"disabledButton","click #activity-link-preview-button":"toggleURLInput","click #activity-gif-button":"toggleGifSelector","click #activity-media-button":"toggleMediaSelector","click #activity-document-button":"toggleDocumentSelector","click #activity-video-button":"toggleVideoSelector","click .post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )":"activeButton","click .post-elements-buttons-item.post-gif:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-media:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-video:not(.disable)":"activeVideoButton","click .post-elements-buttons-item:not(.post-gif):not(.active)":"scrollToMedia"},gifMediaSearchDropdownView:!1,initialize:function(){document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),w(document).on("click",_.bind(this.closePickersOnClick,this))},render:function(){return this.$el.html(this.template(this.model.attributes)),this.$self=this.$el.find("#activity-gif-button"),this.$gifPickerEl=this.$el.find(".gif-media-search-dropdown"),this.$emojiPickerEl=w("#whats-new"),this.$el.removeClass("hidden"),setTimeout(function(){var e=w(".activity-form #whats-new-toolbar");e&&(0===e.children(":visible").length?e.addClass("hidden"):e.removeClass("hidden"))},0),this},toggleURLInput:function(e){e.preventDefault(),this.closeMediaSelector(),this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),e=this.model.get("link_scrapping")?new Event("activity_link_preview_close"):new Event("activity_link_preview_open"),document.dispatchEvent(e)},closeURLInput:function(){var e=new Event("activity_link_preview_close");document.dispatchEvent(e)},toggleGifSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest(".post-elements-buttons-item");t.hasClass("no-click")||t.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),this.$gifPickerEl.is(":empty")&&(this.gifMediaSearchDropdownView=new bp.Views.GifMediaSearchDropdown({model:this.model}),this.$gifPickerEl.html(this.gifMediaSearchDropdownView.render().el)),t=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container"),this.$self.hasClass("open")&&t.length&&""==w.trim(t.html())?this.$self.removeClass("open"):this.$self.addClass("open"),"bp_activity_edit"!==e.type&&this.$gifPickerEl.toggleClass("open"))},closeGifSelector:function(){Backbone.trigger("activity_gif_close")},toggleMediaSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),Backbone.trigger("activity_media_toggle"))},toggleDocumentSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeMediaSelector(),this.closeVideoSelector(),Backbone.trigger("activity_document_toggle"))},toggleVideoSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeGifSelector(),Backbone.trigger("activity_video_toggle"))},closeMediaSelector:function(){Backbone.trigger("activity_media_close")},closeDocumentSelector:function(){Backbone.trigger("activity_document_close")},closeVideoSelector:function(){Backbone.trigger("activity_video_close")},closePickersOnEsc:function(e){"Escape"!==e.key&&27!==e.keyCode||_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||(this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},closePickersOnClick:function(e){var e=w(e.target);_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||e.closest(".post-gif").length||((e=e.parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container")).length&&""!==w.trim(e.html())?this.$self.addClass("open"):this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},activeButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"):(this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"),e.currentTarget.classList.add("active"));e=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container");e.length&&""==w.trim(e.html())&&this.$self.removeClass("open")},activeMediaButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"):(this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"),e.currentTarget.classList.add("active"))},activeVideoButton:function(e){this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media").removeClass("active"),w(e.currentTarget).hasClass("active")?e.currentTarget.classList.remove("active"):e.currentTarget.classList.add("active")},disabledButton:function(){Backbone.trigger("onError",BP_Nouveau.activity.params.errors.media_fail,"info noMediaError")},scrollToMedia:function(){var e=this.$el.closest("#whats-new-form").find(".whats-new-scroll-view");e.stop().animate({scrollTop:e[0].scrollHeight},300)}}),bp.Views.ActivityAttachments=bp.View.extend({tagName:"div",id:"whats-new-attachments",activityLinkPreview:null,activityAttachedGifPreview:null,activityMedia:null,activityDocument:null,activityVideo:null,className:"empty",initialize:function(){_.isUndefined(BP_Nouveau.activity.params.link_preview)||(this.activityLinkPreview=new bp.Views.ActivityLinkPreview({model:this.model}),this.views.add(this.activityLinkPreview)),_.isUndefined(window.Dropzone)||(this.activityMedia=new bp.Views.ActivityMedia({model:this.model}),this.views.add(this.activityMedia),this.activityDocument=new bp.Views.ActivityDocument({model:this.model}),this.views.add(this.activityDocument),this.activityVideo=new bp.Views.ActivityVideo({model:this.model}),this.views.add(this.activityVideo)),this.activityAttachedGifPreview=new bp.Views.ActivityAttachedGifPreview({model:this.model}),this.views.add(this.activityAttachedGifPreview)},onClose:function(){bp.draft_activity.data&&(bp.draft_activity.allow_delete_media=!1,bp.draft_activity.display_post=""),_.isNull(this.activityLinkPreview)||this.activityLinkPreview.destroy(),_.isNull(this.activityAttachedGifPreview)||this.activityAttachedGifPreview.destroy(),_.isNull(this.activityMedia)||this.activityMedia.destroy(),_.isNull(this.activityDocument)||this.activityDocument.destroyDocument(),_.isNull(this.activityVideo)||this.activityVideo.destroyVideo()}}),bp.Views.FormButtons=bp.View.extend({tagName:"div",id:"whats-new-actions",initialize:function(){this.views.add(new bp.View({tagName:"ul",id:"whats-new-buttons"})),_.each(this.collection.models,function(e){this.addItemView(e)},this),this.collection.on("change:active",this.isActive,this)},addItemView:function(e){this.views.add("#whats-new-buttons",new bp.Views.FormButton({model:e}))},isActive:function(t){_.each(this.views._views[""],function(e,t){0!==t&&e.remove()}),!0===t.get("active")?(_.each(this.views._views["#whats-new-buttons"],function(e){e.model.get("id")!==t.get("id")&&(e.model.set("active",!1,{silent:!0}),e.$el.removeClass("active"),this.collection.trigger("reset:"+e.model.get("id"),this.model))},this),this.collection.trigger("display:"+t.get("id"),this)):this.collection.trigger("reset:"+t.get("id"),this.model)}}),bp.Views.FormButton=bp.View.extend({tagName:"li",className:"whats-new-button",template:bp.template("activity-post-form-buttons"),events:{click:"setActive"},setActive:function(e){var t=this.model.get("active")||!1;e.preventDefault(),!1===t?(this.$el.addClass("active"),this.model.set("active",!0)):(this.$el.removeClass("active"),this.model.set("active",!1))}}),bp.Views.FormSubmit=bp.View.extend({tagName:"div",id:"whats-new-submit",className:"in-profile",initialize:function(){this.reset=new bp.Views.ActivityInput({type:"reset",id:"aw-whats-new-reset",className:"text-button small",value:BP_Nouveau.activity.strings.cancelButton});var e=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(e=BP_Nouveau.activity.strings.updatePostButton),"scheduled"!==this.model.get("activity_action_type")&&"scheduled"!==this.model.get("activity_status")||(e=BP_Nouveau.activity.strings.updatePostButton),this.submit=new bp.Views.ActivityInput({model:this.model,type:"submit",id:"aw-whats-new-submit",className:"button",name:"aw-whats-new-submit",value:e}),this.views.set([this.submit,this.reset]),this.model.on("change:object",this.updateDisplay,this),this.model.on("change:posting",this.updateStatus,this),this.model.on("change:activity_action_type",this.updateSubmitLabel,this)},updateDisplay:function(e){_.isUndefined(e)||("user"!==e.get("object")?this.$el.removeClass("in-profile"):this.$el.hasClass("in-profile")||this.$el.addClass("in-profile"))},updateStatus:function(e){_.isUndefined(e)||(e.get("posting")?(this.submit.el.disabled=!0,this.reset.el.disabled=!0,this.submit.el.classList.add("loading")):(this.submit.el.disabled=!1,this.reset.el.disabled=!1,this.submit.el.classList.remove("loading")))},updateSubmitLabel:function(e){var t=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(t=BP_Nouveau.activity.strings.updatePostButton),"scheduled"===e.get("activity_action_type")||"scheduled"===this.model.get("activity_status")?this.submit.el.value=void 0!==BP_Nouveau.activity_schedule?BP_Nouveau.activity_schedule.strings.schedulePostButton:"":this.submit.el.value=t}}),bp.Views.EditActivityPostIn=bp.View.extend({template:bp.template("activity-edit-postin"),initialize:function(){this.model.on("change",this.render,this)},render:function(){return this.$el.html(this.template(this.model.attributes)),this}}),bp.Views.FormSubmitWrapper=bp.View.extend({tagName:"div",id:"activity-form-submit-wrapper",initialize:function(){w("#whats-new-form").addClass("focus-in").parent().addClass("modal-popup").closest("body").addClass("activity-modal-open"),w("#bp-nouveau-activity-form-placeholder").show(),this.views.add(new bp.Views.ActivityInput({model:this.model,type:"button",id:"discard-draft-activity",className:"button outline",name:"discard-draft-activity",value:BP_Nouveau.activity.strings.discardButton})),void 0!==bp.Views.activitySchedulePost&&this.views.add(new bp.Views.activitySchedulePost({model:this.model})),this.views.add(new bp.Views.FormSubmit({model:this.model}))}}),bp.Views.PostForm=bp.View.extend({tagName:"form",className:"activity-form",id:"whats-new-form",attributes:{name:"whats-new-form",method:"post"},events:{"focus #whats-new":"displayFull","input #whats-new":"postValidate",reset:"resetForm",submit:"postUpdate",keydown:"postUpdate","click #whats-new-toolbar":"triggerDisplayFull","change .medium-editor-toolbar-input":"mediumLink","click #discard-draft-activity":"discardDraftActivity"},initialize:function(){var e,t=_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"]);_.isUndefined(BP_Nouveau.activity_schedule)||(e=_.pick(BP_Nouveau.activity_schedule.params,["can_schedule_in_feed"]),t=_.extend(t,e)),this.model=new bp.Models.Activity(t),this.listenTo(Backbone,"mediaprivacy",this.updateMultiMediaOptions),this.listenTo(Backbone,"mediaprivacytoolbar",this.updateMultiMediaToolbar),this.listenTo(Backbone,"onError",this.onError),this.listenTo(Backbone,"cleanFeedBack",this.cleanFeedback),this.listenTo(Backbone,"triggerToastMessage",this.triggerToastMessage),"user"===BP_Nouveau.activity.params.object&&(BP_Nouveau.activity.params.access_control_settings.can_create_activity?this.$el.removeClass("bp-hide"):this.$el.addClass("bp-hide")),this.resetModel=this.model.clone(),this.views.set([new bp.Views.ActivityHeader({model:this.model}),new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.PrivacyStage({model:this.model}),new bp.Views.FormContent({activity:this.model,model:this.model}),new bp.Views.EditorToolbar({model:this.model}),new bp.Views.ActivityToolbar({model:this.model})]),this.model.on("change:errors",this.displayFeedback,this);var i=this;w(document).ready(function(e){w("#whats-new-form").closest("body").addClass("initial-post-form-open"),w("body").hasClass("initial-post-form-open")&&(i.displayFull(e),i.$el.closest(".activity-update-form").find("#aw-whats-new-reset").trigger("click")),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||!(!_.isUndefined(BP_Nouveau.media.emoji.profile)&&BP_Nouveau.media.emoji.profile||!_.isUndefined(BP_Nouveau.media.emoji.groups)&&BP_Nouveau.media.emoji.groups)||w("#whats-new").emojioneArea({standalone:!0,hideSource:!1,container:"#editor-toolbar > .post-emoji",autocomplete:!1,pickerPosition:"bottom",hidePickerOnBlur:!0,useInternalCDN:!1,events:{emojibtn_click:function(){var e;w("#whats-new")[0].emojioneArea.hidePicker(),window.getSelection&&document.createRange?(e=window.getSelection&&window.getSelection())&&0/gi,"\n").replace(/<\/div>/gi,""));""===(t=t.replace(/ /g," ")).replace(/

/gi,"").replace(/<\/p>/gi,"").replace(/
/gi,"")&&(e[0].innerHTML=""),""!==w(w.parseHTML(t)).text().trim()||t.includes('class="emoji"')||!_.isUndefined(this.model.get("link_success"))&&!0===this.model.get("link_success")||!_.isUndefined(this.model.get("video"))&&0!==this.model.get("video").length||!_.isUndefined(this.model.get("document"))&&0!==this.model.get("document").length||!_.isUndefined(this.model.get("media"))&&0!==this.model.get("media").length||!_.isUndefined(this.model.get("gif_data"))&&!_.isEmpty(this.model.get("gif_data"))?this.$el.removeClass("focus-in--empty"):this.$el.addClass("focus-in--empty")},mediumLink:function(){""!==w(".medium-editor-toolbar-input").val()&&w("#whats-new-form").removeClass("focus-in--empty")},displayFull:function(e){var t;6!==this.views._views[""].length&&w(this.views._views[""][6].$el).hasClass("updated")&&(this.cleanFeedback(),w("#whats-new-form").removeClass("bottom-notice")),6===this.views._views[""].length&&("focusin"===e.type&&w("#whats-new-form").closest("body").removeClass("initial-post-form-open").addClass(e.type+"-post-form-open"),this.model.on("change:video change:document change:media change:gif_data change:privacy, change:link_success",this.postValidate,this),t=this,_.each(this.views._views[""],function(e){"message-feedabck"!==e.$el.prop("id")||e.$el.hasClass("noMediaError")||(t.cleanFeedback(),t.$el.removeClass("has-feedback"))}),_.each(this.views._views[""],function(e,t){4

'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer"),_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(typeof BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed||w("#whats-new-form").find(".bb-schedule-post_dropdown_section").removeClass("bp-hide")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),null!==window.activityMediaAction&&(w(".activity-update-form.modal-popup").find("#"+window.activityMediaAction).trigger("click"),window.activityMediaAction=null),0===w(".activity-update-form .activity-update-form-overlay").length&&w(".activity-update-form.modal-popup").prepend('
'),this.activityHideModalEvent(),w("body").hasClass(e.type+"-post-form-open")&&!w("#whats-new-form").hasClass("bp-activity-edit")&&(bp.draft_local_interval||(bp.draft_local_interval=setInterval(function(){bp.Nouveau.Activity.postForm.storeDraftActivity()},3e3)),bp.draft_ajax_interval||(bp.draft_ajax_interval=setInterval(function(){bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)},2e4)),bp.Nouveau.Activity.postForm.displayDraftActivity()),w("a.bp-suggestions-mention:empty").remove())},activityHideModalEvent:function(){w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)})},triggerDisplayFull:function(e){var t,i;e.preventDefault(),(w(e.target).hasClass("toolbar-button")||w(e.target).parent().hasClass("toolbar-button"))&&(window.activityMediaAction=w(e.target).parent().attr("id"),void 0===window.activityMediaAction&&(window.activityMediaAction=w(e.target).attr("id"))),this.$el.hasClass("focus-in")||(t=this.$el.find("#whats-new")[0],i=window.getSelection(),(e=document.createRange()).setStart(t,0),e.setEnd(t,0),i.removeAllRanges(),i.addRange(e))},resetForm:function(){_.each(this.views._views[""],function(e,t){4/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");f.model.set("content",s,{silent:!0}),f.model.set(t,{silent:!0});var d=f.model.get("media");if("group"==f.model.get("object")&&!_.isUndefined(d)&&d.length){for(var n=0;n"+p+' '+u+"
","success",m,!0))),o?b&&"scheduled"!==g.activity_action_type&&w("#activity-"+e.id).length?(w("#activity-"+e.id).replaceWith(e.activity),c=e.activity.indexOf('data-bp-activity="')+'data-bp-activity="'.length,p=e.activity.indexOf('"',c),u=e.activity.substring(c,p),m=f.decodeHtml(u),l=JSON.parse(m),o=w("
").html(l.content).html(),l.content=o,p=(c=w("#activity-modal .activity-list .activity-item")).find(".activity-content").find(".activity-inner"),u=c.find(".bb-media-privacy-wrap").find(".privacy-wrap").find(".privacy"),m=c.find(".bb-media-privacy-wrap").find(".activity-privacy li"),0").addClass("activity-list item-list bp-list")),0
'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),bp.Nouveau.Activity.postForm.resetDraftActivity(!0)}}),bp.Views.PostFormPlaceholder=bp.View.extend({tagName:"form",className:"activity-form-placeholder",id:"whats-new-form-placeholder",initialize:function(){this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),this.resetModel=this.model.clone(),this.views.set([new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.FormPlaceholderContent({activity:this.model,model:this.model}),new bp.Views.ActivityToolbar({model:this.model})])}}),bp.Views.FormPlaceholderContent=bp.View.extend({tagName:"div",id:"whats-new-content-placeholder",initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea-placeholder")),this.views.set("#whats-new-textarea-placeholder",new bp.Views.WhatsNewPlaceholder)}}),bp.Views.WhatsNewPlaceholder=bp.View.extend({tagName:"div",className:"bp-suggestions-placehoder",id:"whats-new-placeholder",attributes:{name:"whats-new-placeholder",cols:"50",rows:"4",placeholder:BP_Nouveau.activity.strings.whatsnewPlaceholder,"aria-label":BP_Nouveau.activity.strings.whatsnewLabel,contenteditable:!0}}),bp.Views.PostGifProfile=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.profile)&&!1===BP_Nouveau.media.gif.profile||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Views.PostGifGroup=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.groups)&&!1===BP_Nouveau.media.gif.groups||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Nouveau.Activity.postForm.start())}((bp,jQuery)); \ No newline at end of file +window.wp=window.wp||{},window.bp=window.bp||{},function(w){bp.Nouveau=bp.Nouveau||{},void 0!==bp.Nouveau.Activity&&"undefined"!=typeof BP_Nouveau&&(_.extend(bp,_.pick(wp,"Backbone","ajax","template")),bp.Models=bp.Models||{},bp.Collections=bp.Collections||{},bp.Views=bp.Views||{},bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",bp.draft_ajax_request=null,bp.old_draft_data=!1,bp.draft_activity={object:!1,data_key:!1,data:!1,post_action:"update",allow_delete_media:!1,display_post:""},bp.draft_local_interval=!1,bp.draft_ajax_interval=!1,bp.draft_content_changed=!1,bp.Nouveau.Activity.postForm={start:function(){this.views=new Backbone.Collection,this.ActivityObjects=new bp.Collections.ActivityObjects,this.buttons=new Backbone.Collection,_.isUndefined(window.Dropzone)||_.isUndefined(BP_Nouveau.media)||this.dropzoneView(),this.postFormView(),this.postFormPlaceholderView(),this.getCurrentDraftActivity(),this.syncDraftActivity(),this.reloadWindow()},postFormView:function(){var e;this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),w("#bp-nouveau-activity-form").length&&(this.postForm=new bp.Views.PostForm,this.views.add({id:"post_form",view:this.postForm}),this.postForm.inject("#bp-nouveau-activity-form"),w(".activity-update-form #user-status-huddle, .activity-update-form #whats-new-content, .activity-update-form #whats-new-attachments").wrapAll('
'),e=this,w(document).on("click",".activity-update-form.modal-popup:not(.bp-activity-edit) .activity-update-form-overlay",function(){e.postForm.$el.hasClass("bp-activity-edit")||(bp.Nouveau.Activity.postForm.clearDraftInterval(),bp.Nouveau.Activity.postForm.collectDraftActivity(),bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)),setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)}),Backbone.trigger("mediaprivacy"))},postFormPlaceholderView:function(){w("#bp-nouveau-activity-form-placeholder").length&&(this.postFormPlaceholder=new bp.Views.PostFormPlaceholder,this.views.add({id:"post_form_placeholder",view:this.postFormPlaceholder}),this.postFormPlaceholder.inject("#bp-nouveau-activity-form-placeholder"),w(".activity-form-placeholder #user-status-huddle, .activity-form-placeholder #whats-new-content-placeholder").wrapAll('
'))},dropzoneView:function(){this.dropzone=null,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:_.isUndefined(BP_Nouveau.media.maxFiles)?10:BP_Nouveau.media.maxFiles,maxFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size},_.isUndefined(BP_Nouveau.media.dropzone_options)||Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options)},displayEditActivity:function(t,i){bp.draft_activity.allow_delete_media=!0,bp.draft_activity.display_post="edit";var e=this;e.postForm.$el.trigger("reset"),e.editActivityData=t,this.model.set("edit_activity",!0),e.postForm.$el.addClass("bp-activity-edit").addClass("loading"),e.postForm.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),e.postForm.$el.removeClass("bp-hide"),e.postForm.$el.find("#whats-new-toolbar").addClass("hidden"),setTimeout(function(){var e=new Event("bp_activity_edit");bp.Nouveau.Activity.postForm.displayEditDraftActivityData(t,e,i)},0)},displayEditActivityForm:function(e,t){var i=w("#bp-nouveau-activity-form"),a=w("#bp-nouveau-activity-form-placeholder"),o=w("#bp-nouveau-single-activity-edit-form-wrap");o.length&&o.show(),bp.privacyEditable=e.can_edit_privacy,bp.album_id=e.album_id,bp.folder_id=e.folder_id,bp.group_id=e.group_id,bp.privacy=e.privacy,this.displayEditActivity(e,t),this.model.set("edit_activity",!0);e=w("#whats-new")[0],t=w("#whats-new-content")[0];window.activity_edit_editor=new window.MediumEditor(e,{placeholder:{text:"",hideOnClick:!0},toolbar:{buttons:["bold","italic","unorderedlist","orderedlist","quote","anchor","pre"],relativeContainer:t,static:!0,updateOnEmptySelection:!0},imageDragging:!1,anchor:{linkValidation:!0}}),window.activity_edit_editor.subscribe("editablePaste",function(t){setTimeout(function(){var e=w(t.target).find("li").filter(function(){return!w(this).parent().is("ul")&&!w(this).parent().is("ol")});0")},0)}),i.addClass("modal-popup").closest("body").addClass("activity-modal-open"),a.show(),setTimeout(function(){w("#whats-new img.emoji").each(function(e,t){w(t).addClass("emojioneemoji");var i=w(t).attr("alt");w(t).attr("data-emoji-char",i),w(t).removeClass("emoji")})},10),this.activityEditHideModalEvent()},activityEditHideModalEvent:function(){var e=this;w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&w(".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset").trigger("click")}),w(document).on("click",".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset",function(){e.postActivityEditHideModal()})},postActivityEditHideModal:function(){bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",w(".activity-update-form.modal-popup").removeClass("modal-popup group-activity").closest("body").removeClass("activity-modal-open");var e=w("#bp-nouveau-activity-form-placeholder"),t=w("#bp-nouveau-single-activity-edit-form-wrap"),i=w("#bp-nouveau-activity-form");w("#whats-new-content").parent().is(".edit-activity-content-wrap")&&w("#whats-new-content").unwrap(),e.hide(),t.length&&t.hide(),i.hasClass("is-bp-hide")&&i.addClass("bp-hide"),bp.Views.ActivityHeader.prototype.resetMultiMediaOptions()},createThumbnailFromUrl:function(t){var i=this;i.dropzone.createThumbnailFromUrl(t,i.dropzone.options.thumbnailWidth,i.dropzone.options.thumbnailHeight,i.dropzone.options.thumbnailMethod,!0,function(e){i.dropzone.emit("thumbnail",t,e),i.dropzone.emit("complete",t)})},displayEditDraftActivityData:function(e,t,i){var a=this;a.postForm.$el.parent("#bp-nouveau-activity-form").removeClass("bp-hide"),a.postForm.$el.find("#whats-new").html(e.content),null!=i&&a.postForm.$el.find("#whats-new").data("activity-url-preview",i);var o,s=a.postForm.$el.find("#whats-new").get(0);s.focus(),0')),bp.privacyEditable||"groups"===e.object?a.postForm.$el.removeClass("bp-activity-edit--privacy-idle"):a.postForm.$el.addClass("bp-activity-edit--privacy-idle"),0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");e.postForm.model.set("content",i,{silent:!0}),e.postForm.model.set(t,{silent:!0});var a=e.postForm.model.get("media");if("group"===e.postForm.model.get("object")&&!_.isUndefined(a)&&a.length){for(var o=0;o"+BP_Nouveau.media.invalid_media_type+". "+t.data.feedback+"
"),this.removeFile(e);bp.draft_content_changed=!0}),bp.Nouveau.Activity.postForm.dropzone.on("error",function(e,t){e.accepted?_.isUndefined(t)||_.isUndefined(t.data)||_.isUndefined(t.data.feedback)?"error"==e.status&&e.xhr&&0==e.xhr.status&&w(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):w(e.previewElement).find(".dz-error-message span").text(t.data.feedback):(Backbone.trigger("onError","
"+BP_Nouveau.media.invalid_media_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.media.length){for(var t in l.media){var i;e.id===l.media[t].id?(_.isUndefined(l.media[t].saved)||l.media[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.media.splice(t,1),l.model.set("media",l.media)):"edit"===bp.draft_activity.display_post||!e.media_edit_data||(i=e.media_edit_data.id)===l.media[t].id&&(l.media.splice(t,1),l.model.set("media",l.media),bp.Nouveau.Media.removeAttachment(i))}var a=l.$el.find(".dz-preview.dz-error").length;l.media.length===a&&l.model.unset("media")}_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("no-click"),l.model.unset("media"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0"+BP_Nouveau.media.invalid_file_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.document.length)for(var t in l.document){var i;e.id===l.document[t].id?(_.isUndefined(l.document[t].saved)||l.document[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.document.splice(t,1),l.model.set("document",l.document)):"edit"===bp.draft_activity.display_post||!e.document_edit_data||(i=e.document_edit_data.id)===l.document[t].id&&(l.document.splice(t,1),l.model.set("document",l.document),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),l.model.unset("document"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(e){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0'),w(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),bp.Nouveau.Activity.postForm.dropzone.on("sending",function(e,t,i){i.append("action","video_upload"),i.append("_wpnonce",BP_Nouveau.nonces.video);i=l.$el.parents("#whats-new-form");i.find("#activity-media-button")&&i.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-gif-button")&&i.find("#activity-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-document-button")&&i.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-video-button")&&i.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("no-click")}),bp.Nouveau.Activity.postForm.dropzone.on("uploadprogress",function(e){l.$el.closest("#whats-new-form").addClass("media-uploading");var t=w(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i;var a=i-e.upload.progress.toFixed(0)/100*i;e.upload.progress<=99?(w(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,w(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),bp.Nouveau.Activity.postForm.dropzone.on("success",function(e,t){if(100===e.upload.progress&&(w(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,w(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),w(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,s,d,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),d=[],a=0,o=(s=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a"+BP_Nouveau.video.invalid_video_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.video.length)for(var t in l.video){var i;e.id===l.video[t].id?(_.isUndefined(l.video[t].saved)||l.video[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.video.splice(t,1),l.model.set("video",l.video)):"edit"===bp.draft_activity.display_post||!e.video_edit_data||(i=e.video_edit_data.id)===l.video[t].id&&(l.video.splice(t,1),l.model.set("video",l.video),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),l.model.unset("video"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),""!==a.find(".ac-textarea").children(".ac-input").text().trim()||0<=i.indexOf("emojioneemoji")?w(a).closest("form").addClass("has-content"):w(a).closest("form").removeClass("has-content")),_.isUndefined(e)||_.isEmpty(t)||!_.isEmpty(this.model.get("gif_data"))||(bp.draft_content_changed=!0)}}),bp.Views.GifMediaSearchDropdown=bp.View.extend({tagName:"div",className:"activity-attached-gif-container",template:bp.template("gif-media-search-dropdown"),total_count:0,offset:0,limit:20,q:null,requests:[],standalone:!1,events:{"keydown .search-query-input":"search","click .found-media-item":"select"},initialize:function(e){this.select=this.select.bind(this),e&&void 0!==e.standalone&&(this.standalone=e.standalone),this.options=e||{},this.giphy=new window.Giphy(BP_Nouveau.media.gif_api_key),this.gifDataItems=new bp.Collections.GifDatas,this.listenTo(this.gifDataItems,"add",this.addOne),this.listenTo(this.gifDataItems,"reset",this.addAll),document.addEventListener("scroll",_.bind(this.loadMore,this),!0)},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.$gifResultItem=this.$el.find(".gif-search-results-list"),this.loadTrending(),this},search:function(e){if("Enter"===e.key||13===e.keyCode)return e.preventDefault(),!1;var t=this;null!=this.Timeout&&clearTimeout(this.Timeout),""!==e.target.value?this.Timeout=setTimeout(function(){this.Timeout=null,t.searchGif(e.target.value)},1e3):this.loadTrending()},searchGif:function(e){var t=this;t.q=e,t.offset=0,t.clearRequests(),t.el.classList.add("loading"),this.$el.find(".gif-no-results").removeClass("show"),this.$el.find(".gif-no-connection").removeClass("show");e=t.giphy.search({q:e,offset:t.offset,fmt:"json",limit:this.limit},function(e){void 0!==e.data.length&&0===e.data.length&&w(t.el).find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&w(t.el).find(".gif-no-connection").addClass("show"),t.gifDataItems.reset(e.data),t.total_count=e.pagination.total_count,t.el.classList.remove("loading")},function(){w(t.el).find(".gif-no-connection").addClass("show")});t.requests.push(e),t.offset=t.offset+t.limit},select:function(e){e.preventDefault(),this.$el.parent().removeClass("open");var t=this.gifDataItems.findWhere({id:e.currentTarget.dataset.id});this.model.set("gif_data",t.attributes);t=this.$el.parents("#whats-new-form");t.find("#activity-document-button")&&t.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-media-button")&&t.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-video-button")&&t.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.parents(".ac-reply-content");t.find(".ac-reply-toolbar .ac-reply-media-button")&&t.find(".ac-reply-toolbar .ac-reply-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-document-button")&&t.find(".ac-reply-toolbar .ac-reply-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-video-button")&&t.find(".ac-reply-toolbar .ac-reply-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.closest("#whats-new-form");(this.standalone?this.$el.closest(".screen-content, .elementor-widget-container, .buddypress-wrap").find("#activity-modal .ac-form"):this.$el.closest(".ac-form")).addClass("has-gif");t=t.find(".whats-new-scroll-view");0=i.scrollHeight&&!i.classList.contains("loading")&&0/g,""):e).indexOf("http://")?i=this.getURL("http://",e):0<=e.indexOf("https://")?i=this.getURL("https://",e):0<=e.indexOf("www.")&&(i=this.getURL("www",e)),""!==i&&((e=document.createElement("a")).href=i,e=e.hostname,-1!==BP_Nouveau.activity.params.excluded_hosts.indexOf(e)&&(i="")),""!==i?this.loadURLPreview(i):void 0!==a&&this.loadURLPreview(a))},getURL:function(e,t){var i="",a=(t=t.replace(/ /g,"")).indexOf(e),o="";if(_.isUndefined(w(w.parseHTML(t)).attr("href"))){for(var s=a;s"===t[s+1]||"<"===t[s]&&"b"===t[s+1]&&"r"===t[s+2]);s++)i+=t[s];"www"===e&&(i=(e="http://")+i)}else i=w(t).attr("href");e=document.createElement("div");e.innerHTML=i;for(var d=e.getElementsByTagName("*");d[0];)d[0].parentNode.removeChild(d[0]);return o=0")},0)}))}),w(document).on("keyup",".activity-form .medium-editor-toolbar-input",function(e){var t=e.target.value;bp.Nouveau.isURL(t)?w(e.target).removeClass("isNotValid").addClass("isValid"):w(e.target).removeClass("isValid").addClass("isNotValid")}),e=bp.Nouveau.getLinkParams(null,"r")||null,_.isNull(e)||w("#message_content").focus())}}),bp.Views.WhatsNewPostIn=bp.View.extend({tagName:"select",id:"whats-new-post-in",attributes:{name:"whats-new-post-in","aria-label":BP_Nouveau.activity.strings.whatsnewpostinLabel},events:{change:"change"},keys:[],initialize:function(){this.model=new Backbone.Model,this.filters=this.options.filters||{},this.$el.html(_.chain(this.filters).map(function(e,t){return{el:w("").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())},change:function(){var e=this.filters[this.el.value];e&&this.model.set({selected:this.el.value,placeholder:e.autocomplete_placeholder})}}),bp.Views.ActivityPrivacy=bp.View.extend({tagName:"div",id:"activity-post-form-privacy",template:bp.template("activity-post-form-privacy"),initialize:function(){this.model=new bp.Models.Activity}}),bp.Views.Item=bp.View.extend({tagName:"div",className:"bp-activity-object",template:bp.template("activity-target-item"),initialize:function(){this.model.get("selected")&&(this.el.className+=" selected")},events:{click:"setObject"},setObject:function(e){e.preventDefault();e=w("#whats-new-form");!0===this.model.get("selected")&&this.model.unset("selected"),e.removeClass("focus-in--blank-group");var t=this;t.model.hasOwnProperty("attributes")&&t.model.attributes.hasOwnProperty("object_type")&&"group"===t.model.attributes.object_type&&((i=_.find(this.model.collection.models,function(e){return e!==t.model&&e.get("selected")}))&&i.set("selected",!1)),this.model.set("selected",!0);var i=this.model.attributes;void 0!==i.group_media&&!1===i.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),void 0!==i.group_document&&!1===i.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),void 0!==i.group_video&&!1===i.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide")}}),bp.Views.AutoComplete=bp.View.extend({tagName:"div",id:"whats-new-post-in-box-items",ac_req:!1,events:{keyup:"autoComplete"},initialize:function(){var e,t,i,a,o=new bp.Views.ActivityInput({type:"text",id:"activity-autocomplete",placeholder:this.options.placeholder||""}).render();this.$el.html(o.$el),o.$el.wrapAll('').after(''),this.$el.append('
'),this.on("ready",this.setFocus,this),"group"===this.options.type&&((o=BP_Nouveau.activity.params.objects.group_list)&&(this.collection.add(o),_.each(this.collection.models,function(e){this.addItemView(e)},this)),e=BP_Nouveau.activity.params.objects.group_total_page,o=BP_Nouveau.activity.params.objects.group_count,1this.collection.models.length&&((t=this).$el.find("#bp-activity-group-ac-items").addClass("group_scrolling load_more_data"),i=this.$el.find("#bp-activity-group-ac-items"),a=1,i.on("scroll",function(){if(window.acScrollPosition=i.scrollTop(),t.$el.find("#bp-activity-group-ac-items").hasClass("load_more_data")){if(e<++a)return t.$el.find("#bp-activity-group-ac-items").removeClass("load_more_data"),!(a=1);t.loadMoreData(t,a)}}))),this.collection.on("add",this.addItemView,this),this.collection.on("reset",this.cleanView,this)},setFocus:function(){var e;this.$el.find("#activity-autocomplete").focus(),w("#bp-activity-group-ac-items .bp-activity-object").length&&(e=w("#bp-activity-group-ac-items"),w(".bp-activity-object").each(function(){w(this).hasClass("selected")&&(e.scrollTop(window.acScrollPosition),e.on("scroll",function(){window.acScrollPosition=w(this).scrollTop()}))}))},addItemView:function(e){e=new bp.Views.Item({model:e});this.$el.find("#bp-activity-group-ac-items").append(e.render().$el)},autoComplete:function(){var e=this,t=w("#activity-autocomplete").val(),i=e.$el.closest("#whats-new-form");0===parseInt(t.length)?(this.autoCompleteCollectionData(e,t),e.$el.find("#bp-activity-group-ac-items").addClass("load_more_data"),e.$el.removeClass("activity-is-autocomplete"),i.addClass("focus-in--blank-group")):(e.$el.addClass("activity-is-autocomplete"),w("#whats-new-post-in-box-items .activity-autocomplete-clear").on("click",function(){w("#activity-autocomplete").val("").keyup(),i.addClass("focus-in--blank-group")})),t.length<2||this.autoCompleteCollectionData(e,t)},autoCompleteCollectionData:function(e,t){this.collection.reset(),this.ac_req&&this.ac_req.abort(),"group"===this.options.type?(this.$el.find("#bp-activity-group-ac-items").html('
'+BP_Nouveau.activity.params.objects.group.finding_group_placeholder+"
"),this.$el.find("#bp-activity-group-ac-items").addClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").html('');var i={type:this.options.type,nonce:BP_Nouveau.nonces.activity};""!==t&&(i.search=t),this.ac_req=this.collection.fetch({data:i,success:_.bind(this.itemFetched,this,e.options.type),error:_.bind(this.itemFetched,this,e.options.type)})},itemFetched:function(e,t){t.length||this.cleanView(e),"group"===e?(this.$el.find("#bp-activity-group-ac-items").find(".groups-selection--finding").remove(),this.$el.find("#bp-activity-group-ac-items").removeClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").find("i.dashicons").remove()},cleanView:function(e){"group"===e?this.$el.find("#bp-activity-group-ac-items").html(''+BP_Nouveau.activity.params.objects.group.no_groups_found+""):this.$el.find("#bp-activity-group-ac-items").html(""),_.each(this.views._views[""],function(e){e.remove()})},loadMoreData:function(i,e){this.$el.find("#bp-activity-group-ac-items .groups-selection--loading").length||this.$el.find("#bp-activity-group-ac-items .bp-activity-object:last").after('
'+BP_Nouveau.activity.params.objects.group.loading_group_placeholder+"
");var a=!1;return(new bp.Collections.fetchCollection).fetch({type:"POST",data:{type:i.options.type,nonce:BP_Nouveau.nonces.activity,page:e,action:"bp_nouveau_get_activity_objects"},success:function(e,t){!0===t.success&&(i.collection.add(t.data),w("#bp-activity-group-ac-items .groups-selection--loading").remove(),a=!0)}}),a}}),bp.Views.UserStatusHuddle=bp.View.extend({tagName:"div",id:"user-status-huddle",className:"bp-activity-huddle",initialize:function(){this.views.add(new bp.Views.CaseAvatar({model:this.model})),this.views.add(new bp.Views.CaseHeading({model:this.model})),this.views.add(new bp.Views.CasePrivacy({model:this.model})),void 0!==bp.Views.PostScheduleTime&&this.views.add(new bp.Views.PostScheduleTime({model:this.model})),w("#whats-new-heading, #whats-new-status").wrapAll('
'),setTimeout(function(){w(".activity-singular #whats-new-heading, .activity-singular #whats-new-status, .activity-singular #activity-schedule-section").wrapAll('
')},1e3)}}),bp.Views.CaseAvatar=bp.View.extend({tagName:"div",id:"whats-new-avatar",template:bp.template("activity-post-case-avatar"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CaseHeading=bp.View.extend({tagName:"div",id:"whats-new-heading",template:bp.template("activity-post-case-heading"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CasePrivacy=bp.View.extend({tagName:"div",id:"whats-new-status",template:bp.template("activity-post-case-privacy"),events:{"click #bp-activity-privacy-point":"privacyTarget"},initialize:function(){this.listenTo(Backbone,"privacy:updatestatus",this.updateStatus),this.model.on("change:privacy",this.render,this)},render:function(){var e;return this.$el.html(this.template(this.model.toJSON())),_.isUndefined(BP_Nouveau.activity.params.object)||"group"!==BP_Nouveau.activity.params.object||"group"!==BP_Nouveau.activity.params.object||(this.model.set("item_name",BP_Nouveau.activity.params.item_name),this.model.set("privacy","group"),e=BP_Nouveau.activity.params.item_name,w("#whats-new-form").find(".bp-activity-privacy-status").text(e),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),BP_Nouveau.activity.params.group_avatar&&!1===BP_Nouveau.activity.params.group_avatar.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),bp.draft_activity.data.item_id=BP_Nouveau.activity.params.item_id,bp.draft_activity.data.group_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.group_image=BP_Nouveau.activity.params.group_avatar,bp.draft_activity.data.item_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.privacy="group",bp.draft_activity.data["group-privacy"]="bp-item-opt-"+BP_Nouveau.activity.params.item_id,localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity))),!_.isUndefined(bp.draft_activity)&&""!==bp.draft_activity.object&&"group"===bp.draft_activity.object&&bp.draft_activity.data&&""!==bp.draft_activity.data&&(this.model.set("item_name",bp.draft_activity.data.item_name),this.model.set("privacy","group"),w("#whats-new-form").find(".bp-activity-privacy-status").text(bp.draft_activity.data.item_name),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),bp.draft_activity.data.group_image&&!1===bp.draft_activity.data.group_image.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"))),this},updateStatus:function(){this.model.get("privacy")},privacyTarget:function(e){if(this.$el.find("#bp-activity-privacy-point").hasClass("bp-activity-edit-group")||!_.isUndefined(BP_Nouveau.activity.params.object)&&"group"===BP_Nouveau.activity.params.object||!bp.privacyEditable)return!1;e.preventDefault(),w("#activity-post-form-privacy").show(),w("#whats-new-form").addClass("focus-in--privacy"),Backbone.trigger("privacy:headerupdate"),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.closest("#whats-new-form").find(".bp-activity-privacy__input:checked").val())}}),bp.Views.PrivacyStage=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage",className:"bp-activity-privacy-stage",events:{"click #privacy-status-submit":"privacyStatusSubmit","click #privacy-status-back":"backPrivacySelector","click #privacy-status-group-back":"backGroupSelector","click input.bp-activity-privacy__input":"privacySelector"},initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.PrivacyStageBody({model:this.model}),this.views.add(e)),this.views.add(new bp.Views.PrivacyStageFooter({model:this.model}))},privacyStatusSubmit:function(e){e.preventDefault();var t=this.$el.find(".bp-activity-privacy__input:checked").val();this.model.set("privacy",t),this.model.set("privacy_modal","general"),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}));var i=w("#whats-new-form");i.removeClass("focus-in--privacy focus-in--group"),Backbone.trigger("privacy:updatestatus");var a,e=this.model.attributes.item_id;"group"===t?(a=i.find("#bp-item-opt-"+e).data("title"),i.find(".bp-activity-privacy-status").text(a),i.find("#bp-activity-privacy-point").removeClass().addClass(t),this.model.set("item_name",a),this.model.set("group_name",a),this.model.attributes.group_image&&!1===this.model.attributes.group_image.includes("mystery-group")?(i.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon"),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").html('')):(i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model})),a=i.find("#bp-item-opt-"+e).data("allow-schedule-post"),_.isUndefined(a)||"enabled"!==a?"scheduled"===this.model.attributes.activity_action_type?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide"),Backbone.trigger("onError",BP_Nouveau.activity_schedule.strings.notAllowScheduleWarning,"error")):(this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):(this.model.set("schedule_allowed",a),i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"))):(_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"),e=this.model.attributes.privacy,a=i.find("#"+e).data("title"),i.find("#bp-activity-privacy-point").removeClass().addClass(e),i.find(".bp-activity-privacy-status").text(a),i.find(".bp-activity-privacy__input#"+e).prop("checked",!0),i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"),this.model.set("item_id",0),this.model.set("item_name",""),this.model.set("group_name",""),this.model.set("group_image",""),this.model.set("group-privacy",""),bp.draft_activity.data.item_id=0,bp.draft_activity.data.group_name="",bp.draft_activity.data.group_image="",bp.draft_activity.data.item_name="",bp.draft_activity.data.privacy=e,bp.draft_activity.data["group-privacy"]="",localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity)))},backPrivacySelector:function(e){e.preventDefault();e=this.model.get("privacy");w("#whats-new-form").removeClass("focus-in--privacy focus-in--group"),this.model.set("privacy_modal","general"),this.$el.find("input#"+e).prop("checked",!0),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.find(".bp-activity-privacy__input:checked").val())},backGroupSelector:function(e){e.preventDefault();var t=w("#whats-new-form");this.model.set("privacy_modal","profile"),t.removeClass("focus-in--group");e=this.model.get("privacy");this.$el.find("input#"+e).prop("checked",!0),w("#activity-post-form-privacy").show(),t.removeClass("focus-in--blank-group")},privacySelector:function(e){var t=w("#whats-new-form");"group"===w(e.currentTarget).val()?(w(e.currentTarget).closest("#whats-new-privacy-stage").find("#whats-new-post-in").val("group").trigger("change"),t.addClass("focus-in--group"),this.model.set("privacy_modal","group"),this.model.set("object",w(e.currentTarget).val()),w("#activity-post-form-privacy").hide(),0===this.model.attributes.item_id&&t.addClass("focus-in--blank-group")):(w("#privacy-status-submit").click(),this.model.set("object","user"),Backbone.trigger("mediaprivacytoolbar"))}}),bp.Views.PrivacyStageBody=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-body",className:"privacy-status-form-body",initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.ActivityPrivacy({model:this.model}),this.views.add(e)),_.isUndefined(BP_Nouveau.activity.params.objects)&&"user"===BP_Nouveau.activity.params.object&&this.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length&&(!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData))?this.views.add(new bp.Views.FormTarget({model:this.model})):!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData)||this.views.add(new bp.Views.EditActivityPostIn({model:this.model}))}}),bp.Views.PrivacyStageFooter=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-footer",className:"privacy-status-form-footer",template:bp.template("activity-post-privacy-stage-footer")}),bp.Views.FormContent=bp.View.extend({tagName:"div",id:"whats-new-content",events:{"click .medium-editor-toolbar-actions":"focusEditor","input #whats-new":"focusEditorOnChange","click .medium-editor-toolbar li.close-btn":"hideToolbarSelector"},initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea")),this.$el.append(''),this.views.set("#whats-new-textarea",new bp.Views.WhatsNew({activity:this.options.activity}))},hideToolbarSelector:function(e){e.preventDefault(),w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar").removeClass("active")},focusEditor:function(e){null===window.activity_editor.exportSelection()&&w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus(),e.preventDefault()},focusEditorOnChange:function(e){var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");setTimeout(function(){t.addClass("medium-editor-toolbar-active"),w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus()},0)}}),bp.Views.FormOptions=bp.View.extend({tagName:"div",id:"whats-new-options",template:bp.template("activity-post-form-options")}),bp.Views.FormTarget=bp.View.extend({tagName:"div",id:"whats-new-post-in-box",className:"in-profile",initialize:function(){var e=new bp.Views.WhatsNewPostIn({filters:BP_Nouveau.activity.params.objects});this.views.add(e),e.model.on("change",this.attachAutocomplete,this),bp.Nouveau.Activity.postForm.ActivityObjects.on("change:selected",this.postIn,this),this.toggleMultiMediaOptions()},attachAutocomplete:function(e){0!==bp.Nouveau.Activity.postForm.ActivityObjects.models.length&&bp.Nouveau.Activity.postForm.ActivityObjects.reset(),_.each(this.views._views[""],function(e){_.isUndefined(e.collection)||e.remove()}),"profile"!==e.get("selected")?(this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:e.get("selected"),placeholder:e.get("placeholder")})),this.model.set("object",e.get("selected"))):this.model.set({object:"user",item_id:0}),this.updateDisplay(),this.toggleMultiMediaOptions()},postIn:function(e){if(_.isUndefined(e.get("id")))return this.model.set("item_id",0),void this.attachAutocomplete(new Backbone.Model({selected:this.model.get("object")}));this.model.set("item_id",e.get("id")),"group"===this.model.get("object")?(this.views.remove("#whats-new-post-in-box-items"),this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:this.model.get("object"),placeholder:BP_Nouveau.activity.params.objects.group.autocomplete_placeholder})),this.model.set("object",this.model.get("object")),this.model.set("group_name",e.get("name")),this.model.set("item_name",e.get("name")),this.model.set("group_image",e.get("avatar_url")),this.model.set("group_url",e.get("group_url"))):this.views.set("#whats-new-post-in-box-items",new bp.Views.Item({model:e}))},updateDisplay:function(){"user"!==this.model.get("object")?(this.$el.removeClass(),w("#activity-post-form-privacy").hide()):this.$el.hasClass("in-profile")||(this.$el.addClass("in-profile"),w("#activity-post-form-privacy").show())},toggleMultiMediaOptions:function(){_.isUndefined(BP_Nouveau.media)||("user"!==this.model.get("object")?(!1===BP_Nouveau.media.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model}),!1===BP_Nouveau.media.emoji.groups?(w("#whats-new-textarea").find("img.emojioneemoji").remove(),w("#editor-toolbar .post-emoji").addClass("post-emoji-hide")):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")):(!1===BP_Nouveau.media.profile_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.profile_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.profile_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}),!1===BP_Nouveau.media.emoji.profile?(w("#editor-toolbar .post-emoji").addClass("post-emoji-hide"),w("#whats-new-textarea").find("img.emojioneemoji").remove()):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")),w(".medium-editor-toolbar").removeClass("active medium-editor-toolbar-active"),w("#show-toolbar-button").removeClass("active"),w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip",w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip-show")))}}),bp.Views.EditorToolbar=bp.View.extend({tagName:"div",id:"editor-toolbar",template:bp.template("editor-toolbar"),events:{"click .show-toolbar":"toggleToolbarSelector","click .post-mention":"triggerMention"},toggleToolbarSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");t.hasClass("active")||bp.Nouveau.mediumEditorButtonsWarp(t),w(e.currentTarget).find(".toolbar-button").toggleClass("active"),w(e.currentTarget).find(".toolbar-button").hasClass("active")?(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-hide")),null!=window.activity_editor.exportSelection()&&t.addClass("medium-editor-toolbar-active")):(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-show")),null===window.activity_editor.exportSelection()&&t.removeClass("medium-editor-toolbar-active"),t.find("li.medium-editor-action-more").removeClass("active")),w(window.activity_editor.elements[0]).focus(),t.toggleClass("medium-editor-toolbar-active active")},triggerMention:function(e){e.preventDefault();var a=this.$el,o=a.closest(".activity-update-form").find("#whats-new"),s=a.closest(".whats-new-scroll-view").scrollTop();setTimeout(function(){var e;o.focus(),window.activityCaretPosition&&(window.getSelection&&document.createRange?((t=document.createRange()).setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),t.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),(e=window.getSelection()).removeAllRanges(),e.addRange(t)):((i=document.body.createTextRange()).moveToElementText(o[0]),i.setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),i.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),i.select()));var t=window.getSelection().getRangeAt(0).cloneRange();t.collapse(!0),t.setStart(o[0],0);var i=t.toString().slice(-1);w(t.endContainer.parentElement).hasClass("atwho-inserted")||(""===i.trim()?document.execCommand("insertText",!1,"@"):"@"!==i&&document.execCommand("insertText",!1," @")),o.trigger("keyup"),setTimeout(function(){o.trigger("keyup"),a.closest(".whats-new-scroll-view").scrollTop(s)},0)},0)}}),bp.Views.ActivityToolbar=bp.View.extend({tagName:"div",id:"whats-new-toolbar",template:bp.template("whats-new-toolbar"),events:{"click .post-elements-buttons-item.disable .toolbar-button":"disabledButton","click #activity-link-preview-button":"toggleURLInput","click #activity-gif-button":"toggleGifSelector","click #activity-media-button":"toggleMediaSelector","click #activity-document-button":"toggleDocumentSelector","click #activity-video-button":"toggleVideoSelector","click .post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )":"activeButton","click .post-elements-buttons-item.post-gif:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-media:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-video:not(.disable)":"activeVideoButton","click .post-elements-buttons-item:not(.post-gif):not(.active)":"scrollToMedia"},gifMediaSearchDropdownView:!1,initialize:function(){document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),w(document).on("click",_.bind(this.closePickersOnClick,this))},render:function(){return this.$el.html(this.template(this.model.attributes)),this.$self=this.$el.find("#activity-gif-button"),this.$gifPickerEl=this.$el.find(".gif-media-search-dropdown"),this.$emojiPickerEl=w("#whats-new"),this.$el.removeClass("hidden"),setTimeout(function(){var e=w(".activity-form #whats-new-toolbar");e&&(0===e.children(":visible").length?e.addClass("hidden"):e.removeClass("hidden"))},0),this},toggleURLInput:function(e){e.preventDefault(),this.closeMediaSelector(),this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),e=this.model.get("link_scrapping")?new Event("activity_link_preview_close"):new Event("activity_link_preview_open"),document.dispatchEvent(e)},closeURLInput:function(){var e=new Event("activity_link_preview_close");document.dispatchEvent(e)},toggleGifSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest(".post-elements-buttons-item");t.hasClass("no-click")||t.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),this.$gifPickerEl.is(":empty")&&(this.gifMediaSearchDropdownView=new bp.Views.GifMediaSearchDropdown({model:this.model}),this.$gifPickerEl.html(this.gifMediaSearchDropdownView.render().el)),t=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container"),this.$self.hasClass("open")&&t.length&&""==w.trim(t.html())?this.$self.removeClass("open"):this.$self.addClass("open"),"bp_activity_edit"!==e.type&&this.$gifPickerEl.toggleClass("open"))},closeGifSelector:function(){Backbone.trigger("activity_gif_close")},toggleMediaSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),Backbone.trigger("activity_media_toggle"))},toggleDocumentSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeMediaSelector(),this.closeVideoSelector(),Backbone.trigger("activity_document_toggle"))},toggleVideoSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeGifSelector(),Backbone.trigger("activity_video_toggle"))},closeMediaSelector:function(){Backbone.trigger("activity_media_close")},closeDocumentSelector:function(){Backbone.trigger("activity_document_close")},closeVideoSelector:function(){Backbone.trigger("activity_video_close")},closePickersOnEsc:function(e){"Escape"!==e.key&&27!==e.keyCode||_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||(this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},closePickersOnClick:function(e){var e=w(e.target);_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||e.closest(".post-gif").length||((e=e.parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container")).length&&""!==w.trim(e.html())?this.$self.addClass("open"):this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},activeButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"):(this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"),e.currentTarget.classList.add("active"));e=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container");e.length&&""==w.trim(e.html())&&this.$self.removeClass("open")},activeMediaButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"):(this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"),e.currentTarget.classList.add("active"))},activeVideoButton:function(e){this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media").removeClass("active"),w(e.currentTarget).hasClass("active")?e.currentTarget.classList.remove("active"):e.currentTarget.classList.add("active")},disabledButton:function(){Backbone.trigger("onError",BP_Nouveau.activity.params.errors.media_fail,"info noMediaError")},scrollToMedia:function(){var e=this.$el.closest("#whats-new-form").find(".whats-new-scroll-view");e.stop().animate({scrollTop:e[0].scrollHeight},300)}}),bp.Views.ActivityAttachments=bp.View.extend({tagName:"div",id:"whats-new-attachments",activityLinkPreview:null,activityAttachedGifPreview:null,activityMedia:null,activityDocument:null,activityVideo:null,className:"empty",initialize:function(){_.isUndefined(BP_Nouveau.activity.params.link_preview)||(this.activityLinkPreview=new bp.Views.ActivityLinkPreview({model:this.model}),this.views.add(this.activityLinkPreview)),_.isUndefined(window.Dropzone)||(this.activityMedia=new bp.Views.ActivityMedia({model:this.model}),this.views.add(this.activityMedia),this.activityDocument=new bp.Views.ActivityDocument({model:this.model}),this.views.add(this.activityDocument),this.activityVideo=new bp.Views.ActivityVideo({model:this.model}),this.views.add(this.activityVideo)),this.activityAttachedGifPreview=new bp.Views.ActivityAttachedGifPreview({model:this.model}),this.views.add(this.activityAttachedGifPreview)},onClose:function(){bp.draft_activity.data&&(bp.draft_activity.allow_delete_media=!1,bp.draft_activity.display_post=""),_.isNull(this.activityLinkPreview)||this.activityLinkPreview.destroy(),_.isNull(this.activityAttachedGifPreview)||this.activityAttachedGifPreview.destroy(),_.isNull(this.activityMedia)||this.activityMedia.destroy(),_.isNull(this.activityDocument)||this.activityDocument.destroyDocument(),_.isNull(this.activityVideo)||this.activityVideo.destroyVideo()}}),bp.Views.FormButtons=bp.View.extend({tagName:"div",id:"whats-new-actions",initialize:function(){this.views.add(new bp.View({tagName:"ul",id:"whats-new-buttons"})),_.each(this.collection.models,function(e){this.addItemView(e)},this),this.collection.on("change:active",this.isActive,this)},addItemView:function(e){this.views.add("#whats-new-buttons",new bp.Views.FormButton({model:e}))},isActive:function(t){_.each(this.views._views[""],function(e,t){0!==t&&e.remove()}),!0===t.get("active")?(_.each(this.views._views["#whats-new-buttons"],function(e){e.model.get("id")!==t.get("id")&&(e.model.set("active",!1,{silent:!0}),e.$el.removeClass("active"),this.collection.trigger("reset:"+e.model.get("id"),this.model))},this),this.collection.trigger("display:"+t.get("id"),this)):this.collection.trigger("reset:"+t.get("id"),this.model)}}),bp.Views.FormButton=bp.View.extend({tagName:"li",className:"whats-new-button",template:bp.template("activity-post-form-buttons"),events:{click:"setActive"},setActive:function(e){var t=this.model.get("active")||!1;e.preventDefault(),!1===t?(this.$el.addClass("active"),this.model.set("active",!0)):(this.$el.removeClass("active"),this.model.set("active",!1))}}),bp.Views.FormSubmit=bp.View.extend({tagName:"div",id:"whats-new-submit",className:"in-profile",initialize:function(){this.reset=new bp.Views.ActivityInput({type:"reset",id:"aw-whats-new-reset",className:"text-button small",value:BP_Nouveau.activity.strings.cancelButton});var e=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(e=BP_Nouveau.activity.strings.updatePostButton),"scheduled"!==this.model.get("activity_action_type")&&"scheduled"!==this.model.get("activity_status")||(e=BP_Nouveau.activity.strings.updatePostButton),this.submit=new bp.Views.ActivityInput({model:this.model,type:"submit",id:"aw-whats-new-submit",className:"button",name:"aw-whats-new-submit",value:e}),this.views.set([this.submit,this.reset]),this.model.on("change:object",this.updateDisplay,this),this.model.on("change:posting",this.updateStatus,this),this.model.on("change:activity_action_type",this.updateSubmitLabel,this)},updateDisplay:function(e){_.isUndefined(e)||("user"!==e.get("object")?this.$el.removeClass("in-profile"):this.$el.hasClass("in-profile")||this.$el.addClass("in-profile"))},updateStatus:function(e){_.isUndefined(e)||(e.get("posting")?(this.submit.el.disabled=!0,this.reset.el.disabled=!0,this.submit.el.classList.add("loading")):(this.submit.el.disabled=!1,this.reset.el.disabled=!1,this.submit.el.classList.remove("loading")))},updateSubmitLabel:function(e){var t=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(t=BP_Nouveau.activity.strings.updatePostButton),"scheduled"===e.get("activity_action_type")||"scheduled"===this.model.get("activity_status")?this.submit.el.value=void 0!==BP_Nouveau.activity_schedule?BP_Nouveau.activity_schedule.strings.schedulePostButton:"":this.submit.el.value=t}}),bp.Views.EditActivityPostIn=bp.View.extend({template:bp.template("activity-edit-postin"),initialize:function(){this.model.on("change",this.render,this)},render:function(){return this.$el.html(this.template(this.model.attributes)),this}}),bp.Views.FormSubmitWrapper=bp.View.extend({tagName:"div",id:"activity-form-submit-wrapper",initialize:function(){w("#whats-new-form").addClass("focus-in").parent().addClass("modal-popup").closest("body").addClass("activity-modal-open"),w("#bp-nouveau-activity-form-placeholder").show(),this.views.add(new bp.Views.ActivityInput({model:this.model,type:"button",id:"discard-draft-activity",className:"button outline",name:"discard-draft-activity",value:BP_Nouveau.activity.strings.discardButton})),void 0!==bp.Views.activitySchedulePost&&this.views.add(new bp.Views.activitySchedulePost({model:this.model})),this.views.add(new bp.Views.FormSubmit({model:this.model}))}}),bp.Views.PostForm=bp.View.extend({tagName:"form",className:"activity-form",id:"whats-new-form",attributes:{name:"whats-new-form",method:"post"},events:{"focus #whats-new":"displayFull","input #whats-new":"postValidate",reset:"resetForm",submit:"postUpdate",keydown:"postUpdate","click #whats-new-toolbar":"triggerDisplayFull","change .medium-editor-toolbar-input":"mediumLink","click #discard-draft-activity":"discardDraftActivity"},initialize:function(){var e,t=_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"]);_.isUndefined(BP_Nouveau.activity_schedule)||(e=_.pick(BP_Nouveau.activity_schedule.params,["can_schedule_in_feed"]),t=_.extend(t,e)),this.model=new bp.Models.Activity(t),this.listenTo(Backbone,"mediaprivacy",this.updateMultiMediaOptions),this.listenTo(Backbone,"mediaprivacytoolbar",this.updateMultiMediaToolbar),this.listenTo(Backbone,"onError",this.onError),this.listenTo(Backbone,"cleanFeedBack",this.cleanFeedback),this.listenTo(Backbone,"triggerToastMessage",this.triggerToastMessage),"user"===BP_Nouveau.activity.params.object&&(BP_Nouveau.activity.params.access_control_settings.can_create_activity?this.$el.removeClass("bp-hide"):this.$el.addClass("bp-hide")),this.resetModel=this.model.clone(),this.views.set([new bp.Views.ActivityHeader({model:this.model}),new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.PrivacyStage({model:this.model}),new bp.Views.FormContent({activity:this.model,model:this.model}),new bp.Views.EditorToolbar({model:this.model}),new bp.Views.ActivityToolbar({model:this.model})]),this.model.on("change:errors",this.displayFeedback,this);var i=this;w(document).ready(function(e){w("#whats-new-form").closest("body").addClass("initial-post-form-open"),w("body").hasClass("initial-post-form-open")&&(i.displayFull(e),i.$el.closest(".activity-update-form").find("#aw-whats-new-reset").trigger("click")),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||!(!_.isUndefined(BP_Nouveau.media.emoji.profile)&&BP_Nouveau.media.emoji.profile||!_.isUndefined(BP_Nouveau.media.emoji.groups)&&BP_Nouveau.media.emoji.groups)||w("#whats-new").emojioneArea({standalone:!0,hideSource:!1,container:"#editor-toolbar > .post-emoji",autocomplete:!1,pickerPosition:"bottom",hidePickerOnBlur:!0,useInternalCDN:!1,events:{emojibtn_click:function(){if(w("#whats-new")[0].emojioneArea.hidePicker(),window.getSelection&&document.createRange){var e=window.getSelection();if(e&&0/gi,"\n").replace(/<\/div>/gi,""));""===(t=t.replace(/ /g," ")).replace(/

/gi,"").replace(/<\/p>/gi,"").replace(/
/gi,"")&&(e[0].innerHTML=""),""!==w(w.parseHTML(t)).text().trim()||t.includes('class="emoji"')||!_.isUndefined(this.model.get("link_success"))&&!0===this.model.get("link_success")||!_.isUndefined(this.model.get("video"))&&0!==this.model.get("video").length||!_.isUndefined(this.model.get("document"))&&0!==this.model.get("document").length||!_.isUndefined(this.model.get("media"))&&0!==this.model.get("media").length||!_.isUndefined(this.model.get("gif_data"))&&!_.isEmpty(this.model.get("gif_data"))?this.$el.removeClass("focus-in--empty"):this.$el.addClass("focus-in--empty")},mediumLink:function(){""!==w(".medium-editor-toolbar-input").val()&&w("#whats-new-form").removeClass("focus-in--empty")},displayFull:function(e){var t;6!==this.views._views[""].length&&w(this.views._views[""][6].$el).hasClass("updated")&&(this.cleanFeedback(),w("#whats-new-form").removeClass("bottom-notice")),6===this.views._views[""].length&&("focusin"===e.type&&w("#whats-new-form").closest("body").removeClass("initial-post-form-open").addClass(e.type+"-post-form-open"),this.model.on("change:video change:document change:media change:gif_data change:privacy, change:link_success",this.postValidate,this),t=this,_.each(this.views._views[""],function(e){"message-feedabck"!==e.$el.prop("id")||e.$el.hasClass("noMediaError")||(t.cleanFeedback(),t.$el.removeClass("has-feedback"))}),_.each(this.views._views[""],function(e,t){4

'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer"),_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(typeof BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed||w("#whats-new-form").find(".bb-schedule-post_dropdown_section").removeClass("bp-hide")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),null!==window.activityMediaAction&&(w(".activity-update-form.modal-popup").find("#"+window.activityMediaAction).trigger("click"),window.activityMediaAction=null),0===w(".activity-update-form .activity-update-form-overlay").length&&w(".activity-update-form.modal-popup").prepend('
'),this.activityHideModalEvent(),w("body").hasClass(e.type+"-post-form-open")&&!w("#whats-new-form").hasClass("bp-activity-edit")&&(bp.draft_local_interval||(bp.draft_local_interval=setInterval(function(){bp.Nouveau.Activity.postForm.storeDraftActivity()},3e3)),bp.draft_ajax_interval||(bp.draft_ajax_interval=setInterval(function(){bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)},2e4)),bp.Nouveau.Activity.postForm.displayDraftActivity()),w("a.bp-suggestions-mention:empty").remove())},activityHideModalEvent:function(){w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)})},triggerDisplayFull:function(e){var t,i;e.preventDefault(),(w(e.target).hasClass("toolbar-button")||w(e.target).parent().hasClass("toolbar-button"))&&(window.activityMediaAction=w(e.target).parent().attr("id"),void 0===window.activityMediaAction&&(window.activityMediaAction=w(e.target).attr("id"))),this.$el.hasClass("focus-in")||(t=this.$el.find("#whats-new")[0],i=window.getSelection(),(e=document.createRange()).setStart(t,0),e.setEnd(t,0),i.removeAllRanges(),i.addRange(e))},resetForm:function(){_.each(this.views._views[""],function(e,t){4/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");f.model.set("content",s,{silent:!0}),f.model.set(t,{silent:!0});var d=f.model.get("media");if("group"==f.model.get("object")&&!_.isUndefined(d)&&d.length){for(var n=0;n"+p+' '+u+"
","success",m,!0))),o?b&&"scheduled"!==g.activity_action_type&&w("#activity-"+e.id).length?(w("#activity-"+e.id).replaceWith(e.activity),c=e.activity.indexOf('data-bp-activity="')+'data-bp-activity="'.length,p=e.activity.indexOf('"',c),u=e.activity.substring(c,p),m=f.decodeHtml(u),l=JSON.parse(m),o=w("
").html(l.content).html(),l.content=o,p=(c=w("#activity-modal .activity-list .activity-item")).find(".activity-content").find(".activity-inner"),u=c.find(".bb-media-privacy-wrap").find(".privacy-wrap").find(".privacy"),m=c.find(".bb-media-privacy-wrap").find(".activity-privacy li"),0").addClass("activity-list item-list bp-list")),0
'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),bp.Nouveau.Activity.postForm.resetDraftActivity(!0)}}),bp.Views.PostFormPlaceholder=bp.View.extend({tagName:"form",className:"activity-form-placeholder",id:"whats-new-form-placeholder",initialize:function(){this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),this.resetModel=this.model.clone(),this.views.set([new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.FormPlaceholderContent({activity:this.model,model:this.model}),new bp.Views.ActivityToolbar({model:this.model})])}}),bp.Views.FormPlaceholderContent=bp.View.extend({tagName:"div",id:"whats-new-content-placeholder",initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea-placeholder")),this.views.set("#whats-new-textarea-placeholder",new bp.Views.WhatsNewPlaceholder)}}),bp.Views.WhatsNewPlaceholder=bp.View.extend({tagName:"div",className:"bp-suggestions-placehoder",id:"whats-new-placeholder",attributes:{name:"whats-new-placeholder",cols:"50",rows:"4",placeholder:BP_Nouveau.activity.strings.whatsnewPlaceholder,"aria-label":BP_Nouveau.activity.strings.whatsnewLabel,contenteditable:!0}}),bp.Views.PostGifProfile=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.profile)&&!1===BP_Nouveau.media.gif.profile||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Views.PostGifGroup=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.groups)&&!1===BP_Nouveau.media.gif.groups||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Nouveau.Activity.postForm.start())}((bp,jQuery)); \ No newline at end of file From 26172d11009b0b5dcbdf9dd8afd08cf1700c2407 Mon Sep 17 00:00:00 2001 From: annrra Date: Wed, 28 Aug 2024 22:54:49 +0300 Subject: [PATCH 3/3] [PROD-7859] Revert back changes --- .../js/buddypress-activity-post-form.js | 29 ++----------------- .../js/buddypress-activity-post-form.min.js | 2 +- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js index 7560ecf092..81641696c4 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js @@ -5085,34 +5085,9 @@ window.bp = window.bp || {}; emojibtn_click: function () { $( '#whats-new' )[0].emojioneArea.hidePicker(); if ( window.getSelection && document.createRange ) { //Get caret position when user adds emoji - var sel = window.getSelection(); + var sel = window.getSelection && window.getSelection(); if ( sel && sel.rangeCount > 0 ) { - var range = sel.getRangeAt( 0 ); - - // Check if range is in the parent div container instead of a child node - if ( range.commonAncestorContainer === $( '#whats-new' )[0] ) { - // Set caret in the nearest text node or valid element - var childNodes = $( '#whats-new' )[0].childNodes; - - // Position the caret within the first text node/element - if ( childNodes.length > 0 ) { - for ( var i = 0; i < childNodes.length; i++ ) { - if ( childNodes[i].nodeType === Node.TEXT_NODE || childNodes[i].nodeType === Node.ELEMENT_NODE ) { - range.setStart( childNodes[i], 0 ); - range.setEnd( childNodes[i], 0 ); - break; - } - } - } - } - - // Move caret after the inserted emoji - sel.removeAllRanges(); - range.setStart(range.endContainer, range.endOffset); - range.setEnd(range.endContainer, range.endOffset); - sel.addRange(range); - - window.activityCaretPosition = range; + window.activityCaretPosition = sel.getRangeAt( 0 ); } } else { window.activityCaretPosition = document.selection.createRange(); diff --git a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js index d21540f0a2..abd2af60cb 100644 --- a/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js +++ b/src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.min.js @@ -1 +1 @@ -window.wp=window.wp||{},window.bp=window.bp||{},function(w){bp.Nouveau=bp.Nouveau||{},void 0!==bp.Nouveau.Activity&&"undefined"!=typeof BP_Nouveau&&(_.extend(bp,_.pick(wp,"Backbone","ajax","template")),bp.Models=bp.Models||{},bp.Collections=bp.Collections||{},bp.Views=bp.Views||{},bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",bp.draft_ajax_request=null,bp.old_draft_data=!1,bp.draft_activity={object:!1,data_key:!1,data:!1,post_action:"update",allow_delete_media:!1,display_post:""},bp.draft_local_interval=!1,bp.draft_ajax_interval=!1,bp.draft_content_changed=!1,bp.Nouveau.Activity.postForm={start:function(){this.views=new Backbone.Collection,this.ActivityObjects=new bp.Collections.ActivityObjects,this.buttons=new Backbone.Collection,_.isUndefined(window.Dropzone)||_.isUndefined(BP_Nouveau.media)||this.dropzoneView(),this.postFormView(),this.postFormPlaceholderView(),this.getCurrentDraftActivity(),this.syncDraftActivity(),this.reloadWindow()},postFormView:function(){var e;this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),w("#bp-nouveau-activity-form").length&&(this.postForm=new bp.Views.PostForm,this.views.add({id:"post_form",view:this.postForm}),this.postForm.inject("#bp-nouveau-activity-form"),w(".activity-update-form #user-status-huddle, .activity-update-form #whats-new-content, .activity-update-form #whats-new-attachments").wrapAll('
'),e=this,w(document).on("click",".activity-update-form.modal-popup:not(.bp-activity-edit) .activity-update-form-overlay",function(){e.postForm.$el.hasClass("bp-activity-edit")||(bp.Nouveau.Activity.postForm.clearDraftInterval(),bp.Nouveau.Activity.postForm.collectDraftActivity(),bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)),setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)}),Backbone.trigger("mediaprivacy"))},postFormPlaceholderView:function(){w("#bp-nouveau-activity-form-placeholder").length&&(this.postFormPlaceholder=new bp.Views.PostFormPlaceholder,this.views.add({id:"post_form_placeholder",view:this.postFormPlaceholder}),this.postFormPlaceholder.inject("#bp-nouveau-activity-form-placeholder"),w(".activity-form-placeholder #user-status-huddle, .activity-form-placeholder #whats-new-content-placeholder").wrapAll('
'))},dropzoneView:function(){this.dropzone=null,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:_.isUndefined(BP_Nouveau.media.maxFiles)?10:BP_Nouveau.media.maxFiles,maxFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size},_.isUndefined(BP_Nouveau.media.dropzone_options)||Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options)},displayEditActivity:function(t,i){bp.draft_activity.allow_delete_media=!0,bp.draft_activity.display_post="edit";var e=this;e.postForm.$el.trigger("reset"),e.editActivityData=t,this.model.set("edit_activity",!0),e.postForm.$el.addClass("bp-activity-edit").addClass("loading"),e.postForm.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),e.postForm.$el.removeClass("bp-hide"),e.postForm.$el.find("#whats-new-toolbar").addClass("hidden"),setTimeout(function(){var e=new Event("bp_activity_edit");bp.Nouveau.Activity.postForm.displayEditDraftActivityData(t,e,i)},0)},displayEditActivityForm:function(e,t){var i=w("#bp-nouveau-activity-form"),a=w("#bp-nouveau-activity-form-placeholder"),o=w("#bp-nouveau-single-activity-edit-form-wrap");o.length&&o.show(),bp.privacyEditable=e.can_edit_privacy,bp.album_id=e.album_id,bp.folder_id=e.folder_id,bp.group_id=e.group_id,bp.privacy=e.privacy,this.displayEditActivity(e,t),this.model.set("edit_activity",!0);e=w("#whats-new")[0],t=w("#whats-new-content")[0];window.activity_edit_editor=new window.MediumEditor(e,{placeholder:{text:"",hideOnClick:!0},toolbar:{buttons:["bold","italic","unorderedlist","orderedlist","quote","anchor","pre"],relativeContainer:t,static:!0,updateOnEmptySelection:!0},imageDragging:!1,anchor:{linkValidation:!0}}),window.activity_edit_editor.subscribe("editablePaste",function(t){setTimeout(function(){var e=w(t.target).find("li").filter(function(){return!w(this).parent().is("ul")&&!w(this).parent().is("ol")});0")},0)}),i.addClass("modal-popup").closest("body").addClass("activity-modal-open"),a.show(),setTimeout(function(){w("#whats-new img.emoji").each(function(e,t){w(t).addClass("emojioneemoji");var i=w(t).attr("alt");w(t).attr("data-emoji-char",i),w(t).removeClass("emoji")})},10),this.activityEditHideModalEvent()},activityEditHideModalEvent:function(){var e=this;w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&w(".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset").trigger("click")}),w(document).on("click",".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset",function(){e.postActivityEditHideModal()})},postActivityEditHideModal:function(){bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",w(".activity-update-form.modal-popup").removeClass("modal-popup group-activity").closest("body").removeClass("activity-modal-open");var e=w("#bp-nouveau-activity-form-placeholder"),t=w("#bp-nouveau-single-activity-edit-form-wrap"),i=w("#bp-nouveau-activity-form");w("#whats-new-content").parent().is(".edit-activity-content-wrap")&&w("#whats-new-content").unwrap(),e.hide(),t.length&&t.hide(),i.hasClass("is-bp-hide")&&i.addClass("bp-hide"),bp.Views.ActivityHeader.prototype.resetMultiMediaOptions()},createThumbnailFromUrl:function(t){var i=this;i.dropzone.createThumbnailFromUrl(t,i.dropzone.options.thumbnailWidth,i.dropzone.options.thumbnailHeight,i.dropzone.options.thumbnailMethod,!0,function(e){i.dropzone.emit("thumbnail",t,e),i.dropzone.emit("complete",t)})},displayEditDraftActivityData:function(e,t,i){var a=this;a.postForm.$el.parent("#bp-nouveau-activity-form").removeClass("bp-hide"),a.postForm.$el.find("#whats-new").html(e.content),null!=i&&a.postForm.$el.find("#whats-new").data("activity-url-preview",i);var o,s=a.postForm.$el.find("#whats-new").get(0);s.focus(),0')),bp.privacyEditable||"groups"===e.object?a.postForm.$el.removeClass("bp-activity-edit--privacy-idle"):a.postForm.$el.addClass("bp-activity-edit--privacy-idle"),0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");e.postForm.model.set("content",i,{silent:!0}),e.postForm.model.set(t,{silent:!0});var a=e.postForm.model.get("media");if("group"===e.postForm.model.get("object")&&!_.isUndefined(a)&&a.length){for(var o=0;o"+BP_Nouveau.media.invalid_media_type+". "+t.data.feedback+"
"),this.removeFile(e);bp.draft_content_changed=!0}),bp.Nouveau.Activity.postForm.dropzone.on("error",function(e,t){e.accepted?_.isUndefined(t)||_.isUndefined(t.data)||_.isUndefined(t.data.feedback)?"error"==e.status&&e.xhr&&0==e.xhr.status&&w(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):w(e.previewElement).find(".dz-error-message span").text(t.data.feedback):(Backbone.trigger("onError","
"+BP_Nouveau.media.invalid_media_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.media.length){for(var t in l.media){var i;e.id===l.media[t].id?(_.isUndefined(l.media[t].saved)||l.media[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.media.splice(t,1),l.model.set("media",l.media)):"edit"===bp.draft_activity.display_post||!e.media_edit_data||(i=e.media_edit_data.id)===l.media[t].id&&(l.media.splice(t,1),l.model.set("media",l.media),bp.Nouveau.Media.removeAttachment(i))}var a=l.$el.find(".dz-preview.dz-error").length;l.media.length===a&&l.model.unset("media")}_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("no-click"),l.model.unset("media"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0"+BP_Nouveau.media.invalid_file_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.document.length)for(var t in l.document){var i;e.id===l.document[t].id?(_.isUndefined(l.document[t].saved)||l.document[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.document.splice(t,1),l.model.set("document",l.document)):"edit"===bp.draft_activity.display_post||!e.document_edit_data||(i=e.document_edit_data.id)===l.document[t].id&&(l.document.splice(t,1),l.model.set("document",l.document),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),l.model.unset("document"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(e){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0'),w(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),bp.Nouveau.Activity.postForm.dropzone.on("sending",function(e,t,i){i.append("action","video_upload"),i.append("_wpnonce",BP_Nouveau.nonces.video);i=l.$el.parents("#whats-new-form");i.find("#activity-media-button")&&i.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-gif-button")&&i.find("#activity-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-document-button")&&i.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-video-button")&&i.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("no-click")}),bp.Nouveau.Activity.postForm.dropzone.on("uploadprogress",function(e){l.$el.closest("#whats-new-form").addClass("media-uploading");var t=w(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i;var a=i-e.upload.progress.toFixed(0)/100*i;e.upload.progress<=99?(w(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,w(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),bp.Nouveau.Activity.postForm.dropzone.on("success",function(e,t){if(100===e.upload.progress&&(w(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,w(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),w(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,s,d,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),d=[],a=0,o=(s=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a"+BP_Nouveau.video.invalid_video_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.video.length)for(var t in l.video){var i;e.id===l.video[t].id?(_.isUndefined(l.video[t].saved)||l.video[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.video.splice(t,1),l.model.set("video",l.video)):"edit"===bp.draft_activity.display_post||!e.video_edit_data||(i=e.video_edit_data.id)===l.video[t].id&&(l.video.splice(t,1),l.model.set("video",l.video),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),l.model.unset("video"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),""!==a.find(".ac-textarea").children(".ac-input").text().trim()||0<=i.indexOf("emojioneemoji")?w(a).closest("form").addClass("has-content"):w(a).closest("form").removeClass("has-content")),_.isUndefined(e)||_.isEmpty(t)||!_.isEmpty(this.model.get("gif_data"))||(bp.draft_content_changed=!0)}}),bp.Views.GifMediaSearchDropdown=bp.View.extend({tagName:"div",className:"activity-attached-gif-container",template:bp.template("gif-media-search-dropdown"),total_count:0,offset:0,limit:20,q:null,requests:[],standalone:!1,events:{"keydown .search-query-input":"search","click .found-media-item":"select"},initialize:function(e){this.select=this.select.bind(this),e&&void 0!==e.standalone&&(this.standalone=e.standalone),this.options=e||{},this.giphy=new window.Giphy(BP_Nouveau.media.gif_api_key),this.gifDataItems=new bp.Collections.GifDatas,this.listenTo(this.gifDataItems,"add",this.addOne),this.listenTo(this.gifDataItems,"reset",this.addAll),document.addEventListener("scroll",_.bind(this.loadMore,this),!0)},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.$gifResultItem=this.$el.find(".gif-search-results-list"),this.loadTrending(),this},search:function(e){if("Enter"===e.key||13===e.keyCode)return e.preventDefault(),!1;var t=this;null!=this.Timeout&&clearTimeout(this.Timeout),""!==e.target.value?this.Timeout=setTimeout(function(){this.Timeout=null,t.searchGif(e.target.value)},1e3):this.loadTrending()},searchGif:function(e){var t=this;t.q=e,t.offset=0,t.clearRequests(),t.el.classList.add("loading"),this.$el.find(".gif-no-results").removeClass("show"),this.$el.find(".gif-no-connection").removeClass("show");e=t.giphy.search({q:e,offset:t.offset,fmt:"json",limit:this.limit},function(e){void 0!==e.data.length&&0===e.data.length&&w(t.el).find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&w(t.el).find(".gif-no-connection").addClass("show"),t.gifDataItems.reset(e.data),t.total_count=e.pagination.total_count,t.el.classList.remove("loading")},function(){w(t.el).find(".gif-no-connection").addClass("show")});t.requests.push(e),t.offset=t.offset+t.limit},select:function(e){e.preventDefault(),this.$el.parent().removeClass("open");var t=this.gifDataItems.findWhere({id:e.currentTarget.dataset.id});this.model.set("gif_data",t.attributes);t=this.$el.parents("#whats-new-form");t.find("#activity-document-button")&&t.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-media-button")&&t.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-video-button")&&t.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.parents(".ac-reply-content");t.find(".ac-reply-toolbar .ac-reply-media-button")&&t.find(".ac-reply-toolbar .ac-reply-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-document-button")&&t.find(".ac-reply-toolbar .ac-reply-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-video-button")&&t.find(".ac-reply-toolbar .ac-reply-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.closest("#whats-new-form");(this.standalone?this.$el.closest(".screen-content, .elementor-widget-container, .buddypress-wrap").find("#activity-modal .ac-form"):this.$el.closest(".ac-form")).addClass("has-gif");t=t.find(".whats-new-scroll-view");0=i.scrollHeight&&!i.classList.contains("loading")&&0/g,""):e).indexOf("http://")?i=this.getURL("http://",e):0<=e.indexOf("https://")?i=this.getURL("https://",e):0<=e.indexOf("www.")&&(i=this.getURL("www",e)),""!==i&&((e=document.createElement("a")).href=i,e=e.hostname,-1!==BP_Nouveau.activity.params.excluded_hosts.indexOf(e)&&(i="")),""!==i?this.loadURLPreview(i):void 0!==a&&this.loadURLPreview(a))},getURL:function(e,t){var i="",a=(t=t.replace(/ /g,"")).indexOf(e),o="";if(_.isUndefined(w(w.parseHTML(t)).attr("href"))){for(var s=a;s"===t[s+1]||"<"===t[s]&&"b"===t[s+1]&&"r"===t[s+2]);s++)i+=t[s];"www"===e&&(i=(e="http://")+i)}else i=w(t).attr("href");e=document.createElement("div");e.innerHTML=i;for(var d=e.getElementsByTagName("*");d[0];)d[0].parentNode.removeChild(d[0]);return o=0")},0)}))}),w(document).on("keyup",".activity-form .medium-editor-toolbar-input",function(e){var t=e.target.value;bp.Nouveau.isURL(t)?w(e.target).removeClass("isNotValid").addClass("isValid"):w(e.target).removeClass("isValid").addClass("isNotValid")}),e=bp.Nouveau.getLinkParams(null,"r")||null,_.isNull(e)||w("#message_content").focus())}}),bp.Views.WhatsNewPostIn=bp.View.extend({tagName:"select",id:"whats-new-post-in",attributes:{name:"whats-new-post-in","aria-label":BP_Nouveau.activity.strings.whatsnewpostinLabel},events:{change:"change"},keys:[],initialize:function(){this.model=new Backbone.Model,this.filters=this.options.filters||{},this.$el.html(_.chain(this.filters).map(function(e,t){return{el:w("").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())},change:function(){var e=this.filters[this.el.value];e&&this.model.set({selected:this.el.value,placeholder:e.autocomplete_placeholder})}}),bp.Views.ActivityPrivacy=bp.View.extend({tagName:"div",id:"activity-post-form-privacy",template:bp.template("activity-post-form-privacy"),initialize:function(){this.model=new bp.Models.Activity}}),bp.Views.Item=bp.View.extend({tagName:"div",className:"bp-activity-object",template:bp.template("activity-target-item"),initialize:function(){this.model.get("selected")&&(this.el.className+=" selected")},events:{click:"setObject"},setObject:function(e){e.preventDefault();e=w("#whats-new-form");!0===this.model.get("selected")&&this.model.unset("selected"),e.removeClass("focus-in--blank-group");var t=this;t.model.hasOwnProperty("attributes")&&t.model.attributes.hasOwnProperty("object_type")&&"group"===t.model.attributes.object_type&&((i=_.find(this.model.collection.models,function(e){return e!==t.model&&e.get("selected")}))&&i.set("selected",!1)),this.model.set("selected",!0);var i=this.model.attributes;void 0!==i.group_media&&!1===i.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),void 0!==i.group_document&&!1===i.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),void 0!==i.group_video&&!1===i.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide")}}),bp.Views.AutoComplete=bp.View.extend({tagName:"div",id:"whats-new-post-in-box-items",ac_req:!1,events:{keyup:"autoComplete"},initialize:function(){var e,t,i,a,o=new bp.Views.ActivityInput({type:"text",id:"activity-autocomplete",placeholder:this.options.placeholder||""}).render();this.$el.html(o.$el),o.$el.wrapAll('').after(''),this.$el.append('
'),this.on("ready",this.setFocus,this),"group"===this.options.type&&((o=BP_Nouveau.activity.params.objects.group_list)&&(this.collection.add(o),_.each(this.collection.models,function(e){this.addItemView(e)},this)),e=BP_Nouveau.activity.params.objects.group_total_page,o=BP_Nouveau.activity.params.objects.group_count,1this.collection.models.length&&((t=this).$el.find("#bp-activity-group-ac-items").addClass("group_scrolling load_more_data"),i=this.$el.find("#bp-activity-group-ac-items"),a=1,i.on("scroll",function(){if(window.acScrollPosition=i.scrollTop(),t.$el.find("#bp-activity-group-ac-items").hasClass("load_more_data")){if(e<++a)return t.$el.find("#bp-activity-group-ac-items").removeClass("load_more_data"),!(a=1);t.loadMoreData(t,a)}}))),this.collection.on("add",this.addItemView,this),this.collection.on("reset",this.cleanView,this)},setFocus:function(){var e;this.$el.find("#activity-autocomplete").focus(),w("#bp-activity-group-ac-items .bp-activity-object").length&&(e=w("#bp-activity-group-ac-items"),w(".bp-activity-object").each(function(){w(this).hasClass("selected")&&(e.scrollTop(window.acScrollPosition),e.on("scroll",function(){window.acScrollPosition=w(this).scrollTop()}))}))},addItemView:function(e){e=new bp.Views.Item({model:e});this.$el.find("#bp-activity-group-ac-items").append(e.render().$el)},autoComplete:function(){var e=this,t=w("#activity-autocomplete").val(),i=e.$el.closest("#whats-new-form");0===parseInt(t.length)?(this.autoCompleteCollectionData(e,t),e.$el.find("#bp-activity-group-ac-items").addClass("load_more_data"),e.$el.removeClass("activity-is-autocomplete"),i.addClass("focus-in--blank-group")):(e.$el.addClass("activity-is-autocomplete"),w("#whats-new-post-in-box-items .activity-autocomplete-clear").on("click",function(){w("#activity-autocomplete").val("").keyup(),i.addClass("focus-in--blank-group")})),t.length<2||this.autoCompleteCollectionData(e,t)},autoCompleteCollectionData:function(e,t){this.collection.reset(),this.ac_req&&this.ac_req.abort(),"group"===this.options.type?(this.$el.find("#bp-activity-group-ac-items").html('
'+BP_Nouveau.activity.params.objects.group.finding_group_placeholder+"
"),this.$el.find("#bp-activity-group-ac-items").addClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").html('');var i={type:this.options.type,nonce:BP_Nouveau.nonces.activity};""!==t&&(i.search=t),this.ac_req=this.collection.fetch({data:i,success:_.bind(this.itemFetched,this,e.options.type),error:_.bind(this.itemFetched,this,e.options.type)})},itemFetched:function(e,t){t.length||this.cleanView(e),"group"===e?(this.$el.find("#bp-activity-group-ac-items").find(".groups-selection--finding").remove(),this.$el.find("#bp-activity-group-ac-items").removeClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").find("i.dashicons").remove()},cleanView:function(e){"group"===e?this.$el.find("#bp-activity-group-ac-items").html(''+BP_Nouveau.activity.params.objects.group.no_groups_found+""):this.$el.find("#bp-activity-group-ac-items").html(""),_.each(this.views._views[""],function(e){e.remove()})},loadMoreData:function(i,e){this.$el.find("#bp-activity-group-ac-items .groups-selection--loading").length||this.$el.find("#bp-activity-group-ac-items .bp-activity-object:last").after('
'+BP_Nouveau.activity.params.objects.group.loading_group_placeholder+"
");var a=!1;return(new bp.Collections.fetchCollection).fetch({type:"POST",data:{type:i.options.type,nonce:BP_Nouveau.nonces.activity,page:e,action:"bp_nouveau_get_activity_objects"},success:function(e,t){!0===t.success&&(i.collection.add(t.data),w("#bp-activity-group-ac-items .groups-selection--loading").remove(),a=!0)}}),a}}),bp.Views.UserStatusHuddle=bp.View.extend({tagName:"div",id:"user-status-huddle",className:"bp-activity-huddle",initialize:function(){this.views.add(new bp.Views.CaseAvatar({model:this.model})),this.views.add(new bp.Views.CaseHeading({model:this.model})),this.views.add(new bp.Views.CasePrivacy({model:this.model})),void 0!==bp.Views.PostScheduleTime&&this.views.add(new bp.Views.PostScheduleTime({model:this.model})),w("#whats-new-heading, #whats-new-status").wrapAll('
'),setTimeout(function(){w(".activity-singular #whats-new-heading, .activity-singular #whats-new-status, .activity-singular #activity-schedule-section").wrapAll('
')},1e3)}}),bp.Views.CaseAvatar=bp.View.extend({tagName:"div",id:"whats-new-avatar",template:bp.template("activity-post-case-avatar"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CaseHeading=bp.View.extend({tagName:"div",id:"whats-new-heading",template:bp.template("activity-post-case-heading"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CasePrivacy=bp.View.extend({tagName:"div",id:"whats-new-status",template:bp.template("activity-post-case-privacy"),events:{"click #bp-activity-privacy-point":"privacyTarget"},initialize:function(){this.listenTo(Backbone,"privacy:updatestatus",this.updateStatus),this.model.on("change:privacy",this.render,this)},render:function(){var e;return this.$el.html(this.template(this.model.toJSON())),_.isUndefined(BP_Nouveau.activity.params.object)||"group"!==BP_Nouveau.activity.params.object||"group"!==BP_Nouveau.activity.params.object||(this.model.set("item_name",BP_Nouveau.activity.params.item_name),this.model.set("privacy","group"),e=BP_Nouveau.activity.params.item_name,w("#whats-new-form").find(".bp-activity-privacy-status").text(e),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),BP_Nouveau.activity.params.group_avatar&&!1===BP_Nouveau.activity.params.group_avatar.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),bp.draft_activity.data.item_id=BP_Nouveau.activity.params.item_id,bp.draft_activity.data.group_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.group_image=BP_Nouveau.activity.params.group_avatar,bp.draft_activity.data.item_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.privacy="group",bp.draft_activity.data["group-privacy"]="bp-item-opt-"+BP_Nouveau.activity.params.item_id,localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity))),!_.isUndefined(bp.draft_activity)&&""!==bp.draft_activity.object&&"group"===bp.draft_activity.object&&bp.draft_activity.data&&""!==bp.draft_activity.data&&(this.model.set("item_name",bp.draft_activity.data.item_name),this.model.set("privacy","group"),w("#whats-new-form").find(".bp-activity-privacy-status").text(bp.draft_activity.data.item_name),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),bp.draft_activity.data.group_image&&!1===bp.draft_activity.data.group_image.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"))),this},updateStatus:function(){this.model.get("privacy")},privacyTarget:function(e){if(this.$el.find("#bp-activity-privacy-point").hasClass("bp-activity-edit-group")||!_.isUndefined(BP_Nouveau.activity.params.object)&&"group"===BP_Nouveau.activity.params.object||!bp.privacyEditable)return!1;e.preventDefault(),w("#activity-post-form-privacy").show(),w("#whats-new-form").addClass("focus-in--privacy"),Backbone.trigger("privacy:headerupdate"),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.closest("#whats-new-form").find(".bp-activity-privacy__input:checked").val())}}),bp.Views.PrivacyStage=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage",className:"bp-activity-privacy-stage",events:{"click #privacy-status-submit":"privacyStatusSubmit","click #privacy-status-back":"backPrivacySelector","click #privacy-status-group-back":"backGroupSelector","click input.bp-activity-privacy__input":"privacySelector"},initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.PrivacyStageBody({model:this.model}),this.views.add(e)),this.views.add(new bp.Views.PrivacyStageFooter({model:this.model}))},privacyStatusSubmit:function(e){e.preventDefault();var t=this.$el.find(".bp-activity-privacy__input:checked").val();this.model.set("privacy",t),this.model.set("privacy_modal","general"),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}));var i=w("#whats-new-form");i.removeClass("focus-in--privacy focus-in--group"),Backbone.trigger("privacy:updatestatus");var a,e=this.model.attributes.item_id;"group"===t?(a=i.find("#bp-item-opt-"+e).data("title"),i.find(".bp-activity-privacy-status").text(a),i.find("#bp-activity-privacy-point").removeClass().addClass(t),this.model.set("item_name",a),this.model.set("group_name",a),this.model.attributes.group_image&&!1===this.model.attributes.group_image.includes("mystery-group")?(i.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon"),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").html('')):(i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model})),a=i.find("#bp-item-opt-"+e).data("allow-schedule-post"),_.isUndefined(a)||"enabled"!==a?"scheduled"===this.model.attributes.activity_action_type?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide"),Backbone.trigger("onError",BP_Nouveau.activity_schedule.strings.notAllowScheduleWarning,"error")):(this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):(this.model.set("schedule_allowed",a),i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"))):(_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"),e=this.model.attributes.privacy,a=i.find("#"+e).data("title"),i.find("#bp-activity-privacy-point").removeClass().addClass(e),i.find(".bp-activity-privacy-status").text(a),i.find(".bp-activity-privacy__input#"+e).prop("checked",!0),i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"),this.model.set("item_id",0),this.model.set("item_name",""),this.model.set("group_name",""),this.model.set("group_image",""),this.model.set("group-privacy",""),bp.draft_activity.data.item_id=0,bp.draft_activity.data.group_name="",bp.draft_activity.data.group_image="",bp.draft_activity.data.item_name="",bp.draft_activity.data.privacy=e,bp.draft_activity.data["group-privacy"]="",localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity)))},backPrivacySelector:function(e){e.preventDefault();e=this.model.get("privacy");w("#whats-new-form").removeClass("focus-in--privacy focus-in--group"),this.model.set("privacy_modal","general"),this.$el.find("input#"+e).prop("checked",!0),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.find(".bp-activity-privacy__input:checked").val())},backGroupSelector:function(e){e.preventDefault();var t=w("#whats-new-form");this.model.set("privacy_modal","profile"),t.removeClass("focus-in--group");e=this.model.get("privacy");this.$el.find("input#"+e).prop("checked",!0),w("#activity-post-form-privacy").show(),t.removeClass("focus-in--blank-group")},privacySelector:function(e){var t=w("#whats-new-form");"group"===w(e.currentTarget).val()?(w(e.currentTarget).closest("#whats-new-privacy-stage").find("#whats-new-post-in").val("group").trigger("change"),t.addClass("focus-in--group"),this.model.set("privacy_modal","group"),this.model.set("object",w(e.currentTarget).val()),w("#activity-post-form-privacy").hide(),0===this.model.attributes.item_id&&t.addClass("focus-in--blank-group")):(w("#privacy-status-submit").click(),this.model.set("object","user"),Backbone.trigger("mediaprivacytoolbar"))}}),bp.Views.PrivacyStageBody=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-body",className:"privacy-status-form-body",initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.ActivityPrivacy({model:this.model}),this.views.add(e)),_.isUndefined(BP_Nouveau.activity.params.objects)&&"user"===BP_Nouveau.activity.params.object&&this.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length&&(!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData))?this.views.add(new bp.Views.FormTarget({model:this.model})):!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData)||this.views.add(new bp.Views.EditActivityPostIn({model:this.model}))}}),bp.Views.PrivacyStageFooter=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-footer",className:"privacy-status-form-footer",template:bp.template("activity-post-privacy-stage-footer")}),bp.Views.FormContent=bp.View.extend({tagName:"div",id:"whats-new-content",events:{"click .medium-editor-toolbar-actions":"focusEditor","input #whats-new":"focusEditorOnChange","click .medium-editor-toolbar li.close-btn":"hideToolbarSelector"},initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea")),this.$el.append(''),this.views.set("#whats-new-textarea",new bp.Views.WhatsNew({activity:this.options.activity}))},hideToolbarSelector:function(e){e.preventDefault(),w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar").removeClass("active")},focusEditor:function(e){null===window.activity_editor.exportSelection()&&w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus(),e.preventDefault()},focusEditorOnChange:function(e){var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");setTimeout(function(){t.addClass("medium-editor-toolbar-active"),w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus()},0)}}),bp.Views.FormOptions=bp.View.extend({tagName:"div",id:"whats-new-options",template:bp.template("activity-post-form-options")}),bp.Views.FormTarget=bp.View.extend({tagName:"div",id:"whats-new-post-in-box",className:"in-profile",initialize:function(){var e=new bp.Views.WhatsNewPostIn({filters:BP_Nouveau.activity.params.objects});this.views.add(e),e.model.on("change",this.attachAutocomplete,this),bp.Nouveau.Activity.postForm.ActivityObjects.on("change:selected",this.postIn,this),this.toggleMultiMediaOptions()},attachAutocomplete:function(e){0!==bp.Nouveau.Activity.postForm.ActivityObjects.models.length&&bp.Nouveau.Activity.postForm.ActivityObjects.reset(),_.each(this.views._views[""],function(e){_.isUndefined(e.collection)||e.remove()}),"profile"!==e.get("selected")?(this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:e.get("selected"),placeholder:e.get("placeholder")})),this.model.set("object",e.get("selected"))):this.model.set({object:"user",item_id:0}),this.updateDisplay(),this.toggleMultiMediaOptions()},postIn:function(e){if(_.isUndefined(e.get("id")))return this.model.set("item_id",0),void this.attachAutocomplete(new Backbone.Model({selected:this.model.get("object")}));this.model.set("item_id",e.get("id")),"group"===this.model.get("object")?(this.views.remove("#whats-new-post-in-box-items"),this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:this.model.get("object"),placeholder:BP_Nouveau.activity.params.objects.group.autocomplete_placeholder})),this.model.set("object",this.model.get("object")),this.model.set("group_name",e.get("name")),this.model.set("item_name",e.get("name")),this.model.set("group_image",e.get("avatar_url")),this.model.set("group_url",e.get("group_url"))):this.views.set("#whats-new-post-in-box-items",new bp.Views.Item({model:e}))},updateDisplay:function(){"user"!==this.model.get("object")?(this.$el.removeClass(),w("#activity-post-form-privacy").hide()):this.$el.hasClass("in-profile")||(this.$el.addClass("in-profile"),w("#activity-post-form-privacy").show())},toggleMultiMediaOptions:function(){_.isUndefined(BP_Nouveau.media)||("user"!==this.model.get("object")?(!1===BP_Nouveau.media.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model}),!1===BP_Nouveau.media.emoji.groups?(w("#whats-new-textarea").find("img.emojioneemoji").remove(),w("#editor-toolbar .post-emoji").addClass("post-emoji-hide")):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")):(!1===BP_Nouveau.media.profile_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.profile_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.profile_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}),!1===BP_Nouveau.media.emoji.profile?(w("#editor-toolbar .post-emoji").addClass("post-emoji-hide"),w("#whats-new-textarea").find("img.emojioneemoji").remove()):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")),w(".medium-editor-toolbar").removeClass("active medium-editor-toolbar-active"),w("#show-toolbar-button").removeClass("active"),w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip",w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip-show")))}}),bp.Views.EditorToolbar=bp.View.extend({tagName:"div",id:"editor-toolbar",template:bp.template("editor-toolbar"),events:{"click .show-toolbar":"toggleToolbarSelector","click .post-mention":"triggerMention"},toggleToolbarSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");t.hasClass("active")||bp.Nouveau.mediumEditorButtonsWarp(t),w(e.currentTarget).find(".toolbar-button").toggleClass("active"),w(e.currentTarget).find(".toolbar-button").hasClass("active")?(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-hide")),null!=window.activity_editor.exportSelection()&&t.addClass("medium-editor-toolbar-active")):(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-show")),null===window.activity_editor.exportSelection()&&t.removeClass("medium-editor-toolbar-active"),t.find("li.medium-editor-action-more").removeClass("active")),w(window.activity_editor.elements[0]).focus(),t.toggleClass("medium-editor-toolbar-active active")},triggerMention:function(e){e.preventDefault();var a=this.$el,o=a.closest(".activity-update-form").find("#whats-new"),s=a.closest(".whats-new-scroll-view").scrollTop();setTimeout(function(){var e;o.focus(),window.activityCaretPosition&&(window.getSelection&&document.createRange?((t=document.createRange()).setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),t.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),(e=window.getSelection()).removeAllRanges(),e.addRange(t)):((i=document.body.createTextRange()).moveToElementText(o[0]),i.setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),i.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),i.select()));var t=window.getSelection().getRangeAt(0).cloneRange();t.collapse(!0),t.setStart(o[0],0);var i=t.toString().slice(-1);w(t.endContainer.parentElement).hasClass("atwho-inserted")||(""===i.trim()?document.execCommand("insertText",!1,"@"):"@"!==i&&document.execCommand("insertText",!1," @")),o.trigger("keyup"),setTimeout(function(){o.trigger("keyup"),a.closest(".whats-new-scroll-view").scrollTop(s)},0)},0)}}),bp.Views.ActivityToolbar=bp.View.extend({tagName:"div",id:"whats-new-toolbar",template:bp.template("whats-new-toolbar"),events:{"click .post-elements-buttons-item.disable .toolbar-button":"disabledButton","click #activity-link-preview-button":"toggleURLInput","click #activity-gif-button":"toggleGifSelector","click #activity-media-button":"toggleMediaSelector","click #activity-document-button":"toggleDocumentSelector","click #activity-video-button":"toggleVideoSelector","click .post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )":"activeButton","click .post-elements-buttons-item.post-gif:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-media:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-video:not(.disable)":"activeVideoButton","click .post-elements-buttons-item:not(.post-gif):not(.active)":"scrollToMedia"},gifMediaSearchDropdownView:!1,initialize:function(){document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),w(document).on("click",_.bind(this.closePickersOnClick,this))},render:function(){return this.$el.html(this.template(this.model.attributes)),this.$self=this.$el.find("#activity-gif-button"),this.$gifPickerEl=this.$el.find(".gif-media-search-dropdown"),this.$emojiPickerEl=w("#whats-new"),this.$el.removeClass("hidden"),setTimeout(function(){var e=w(".activity-form #whats-new-toolbar");e&&(0===e.children(":visible").length?e.addClass("hidden"):e.removeClass("hidden"))},0),this},toggleURLInput:function(e){e.preventDefault(),this.closeMediaSelector(),this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),e=this.model.get("link_scrapping")?new Event("activity_link_preview_close"):new Event("activity_link_preview_open"),document.dispatchEvent(e)},closeURLInput:function(){var e=new Event("activity_link_preview_close");document.dispatchEvent(e)},toggleGifSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest(".post-elements-buttons-item");t.hasClass("no-click")||t.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),this.$gifPickerEl.is(":empty")&&(this.gifMediaSearchDropdownView=new bp.Views.GifMediaSearchDropdown({model:this.model}),this.$gifPickerEl.html(this.gifMediaSearchDropdownView.render().el)),t=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container"),this.$self.hasClass("open")&&t.length&&""==w.trim(t.html())?this.$self.removeClass("open"):this.$self.addClass("open"),"bp_activity_edit"!==e.type&&this.$gifPickerEl.toggleClass("open"))},closeGifSelector:function(){Backbone.trigger("activity_gif_close")},toggleMediaSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),Backbone.trigger("activity_media_toggle"))},toggleDocumentSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeMediaSelector(),this.closeVideoSelector(),Backbone.trigger("activity_document_toggle"))},toggleVideoSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeGifSelector(),Backbone.trigger("activity_video_toggle"))},closeMediaSelector:function(){Backbone.trigger("activity_media_close")},closeDocumentSelector:function(){Backbone.trigger("activity_document_close")},closeVideoSelector:function(){Backbone.trigger("activity_video_close")},closePickersOnEsc:function(e){"Escape"!==e.key&&27!==e.keyCode||_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||(this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},closePickersOnClick:function(e){var e=w(e.target);_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||e.closest(".post-gif").length||((e=e.parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container")).length&&""!==w.trim(e.html())?this.$self.addClass("open"):this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},activeButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"):(this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"),e.currentTarget.classList.add("active"));e=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container");e.length&&""==w.trim(e.html())&&this.$self.removeClass("open")},activeMediaButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"):(this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"),e.currentTarget.classList.add("active"))},activeVideoButton:function(e){this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media").removeClass("active"),w(e.currentTarget).hasClass("active")?e.currentTarget.classList.remove("active"):e.currentTarget.classList.add("active")},disabledButton:function(){Backbone.trigger("onError",BP_Nouveau.activity.params.errors.media_fail,"info noMediaError")},scrollToMedia:function(){var e=this.$el.closest("#whats-new-form").find(".whats-new-scroll-view");e.stop().animate({scrollTop:e[0].scrollHeight},300)}}),bp.Views.ActivityAttachments=bp.View.extend({tagName:"div",id:"whats-new-attachments",activityLinkPreview:null,activityAttachedGifPreview:null,activityMedia:null,activityDocument:null,activityVideo:null,className:"empty",initialize:function(){_.isUndefined(BP_Nouveau.activity.params.link_preview)||(this.activityLinkPreview=new bp.Views.ActivityLinkPreview({model:this.model}),this.views.add(this.activityLinkPreview)),_.isUndefined(window.Dropzone)||(this.activityMedia=new bp.Views.ActivityMedia({model:this.model}),this.views.add(this.activityMedia),this.activityDocument=new bp.Views.ActivityDocument({model:this.model}),this.views.add(this.activityDocument),this.activityVideo=new bp.Views.ActivityVideo({model:this.model}),this.views.add(this.activityVideo)),this.activityAttachedGifPreview=new bp.Views.ActivityAttachedGifPreview({model:this.model}),this.views.add(this.activityAttachedGifPreview)},onClose:function(){bp.draft_activity.data&&(bp.draft_activity.allow_delete_media=!1,bp.draft_activity.display_post=""),_.isNull(this.activityLinkPreview)||this.activityLinkPreview.destroy(),_.isNull(this.activityAttachedGifPreview)||this.activityAttachedGifPreview.destroy(),_.isNull(this.activityMedia)||this.activityMedia.destroy(),_.isNull(this.activityDocument)||this.activityDocument.destroyDocument(),_.isNull(this.activityVideo)||this.activityVideo.destroyVideo()}}),bp.Views.FormButtons=bp.View.extend({tagName:"div",id:"whats-new-actions",initialize:function(){this.views.add(new bp.View({tagName:"ul",id:"whats-new-buttons"})),_.each(this.collection.models,function(e){this.addItemView(e)},this),this.collection.on("change:active",this.isActive,this)},addItemView:function(e){this.views.add("#whats-new-buttons",new bp.Views.FormButton({model:e}))},isActive:function(t){_.each(this.views._views[""],function(e,t){0!==t&&e.remove()}),!0===t.get("active")?(_.each(this.views._views["#whats-new-buttons"],function(e){e.model.get("id")!==t.get("id")&&(e.model.set("active",!1,{silent:!0}),e.$el.removeClass("active"),this.collection.trigger("reset:"+e.model.get("id"),this.model))},this),this.collection.trigger("display:"+t.get("id"),this)):this.collection.trigger("reset:"+t.get("id"),this.model)}}),bp.Views.FormButton=bp.View.extend({tagName:"li",className:"whats-new-button",template:bp.template("activity-post-form-buttons"),events:{click:"setActive"},setActive:function(e){var t=this.model.get("active")||!1;e.preventDefault(),!1===t?(this.$el.addClass("active"),this.model.set("active",!0)):(this.$el.removeClass("active"),this.model.set("active",!1))}}),bp.Views.FormSubmit=bp.View.extend({tagName:"div",id:"whats-new-submit",className:"in-profile",initialize:function(){this.reset=new bp.Views.ActivityInput({type:"reset",id:"aw-whats-new-reset",className:"text-button small",value:BP_Nouveau.activity.strings.cancelButton});var e=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(e=BP_Nouveau.activity.strings.updatePostButton),"scheduled"!==this.model.get("activity_action_type")&&"scheduled"!==this.model.get("activity_status")||(e=BP_Nouveau.activity.strings.updatePostButton),this.submit=new bp.Views.ActivityInput({model:this.model,type:"submit",id:"aw-whats-new-submit",className:"button",name:"aw-whats-new-submit",value:e}),this.views.set([this.submit,this.reset]),this.model.on("change:object",this.updateDisplay,this),this.model.on("change:posting",this.updateStatus,this),this.model.on("change:activity_action_type",this.updateSubmitLabel,this)},updateDisplay:function(e){_.isUndefined(e)||("user"!==e.get("object")?this.$el.removeClass("in-profile"):this.$el.hasClass("in-profile")||this.$el.addClass("in-profile"))},updateStatus:function(e){_.isUndefined(e)||(e.get("posting")?(this.submit.el.disabled=!0,this.reset.el.disabled=!0,this.submit.el.classList.add("loading")):(this.submit.el.disabled=!1,this.reset.el.disabled=!1,this.submit.el.classList.remove("loading")))},updateSubmitLabel:function(e){var t=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(t=BP_Nouveau.activity.strings.updatePostButton),"scheduled"===e.get("activity_action_type")||"scheduled"===this.model.get("activity_status")?this.submit.el.value=void 0!==BP_Nouveau.activity_schedule?BP_Nouveau.activity_schedule.strings.schedulePostButton:"":this.submit.el.value=t}}),bp.Views.EditActivityPostIn=bp.View.extend({template:bp.template("activity-edit-postin"),initialize:function(){this.model.on("change",this.render,this)},render:function(){return this.$el.html(this.template(this.model.attributes)),this}}),bp.Views.FormSubmitWrapper=bp.View.extend({tagName:"div",id:"activity-form-submit-wrapper",initialize:function(){w("#whats-new-form").addClass("focus-in").parent().addClass("modal-popup").closest("body").addClass("activity-modal-open"),w("#bp-nouveau-activity-form-placeholder").show(),this.views.add(new bp.Views.ActivityInput({model:this.model,type:"button",id:"discard-draft-activity",className:"button outline",name:"discard-draft-activity",value:BP_Nouveau.activity.strings.discardButton})),void 0!==bp.Views.activitySchedulePost&&this.views.add(new bp.Views.activitySchedulePost({model:this.model})),this.views.add(new bp.Views.FormSubmit({model:this.model}))}}),bp.Views.PostForm=bp.View.extend({tagName:"form",className:"activity-form",id:"whats-new-form",attributes:{name:"whats-new-form",method:"post"},events:{"focus #whats-new":"displayFull","input #whats-new":"postValidate",reset:"resetForm",submit:"postUpdate",keydown:"postUpdate","click #whats-new-toolbar":"triggerDisplayFull","change .medium-editor-toolbar-input":"mediumLink","click #discard-draft-activity":"discardDraftActivity"},initialize:function(){var e,t=_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"]);_.isUndefined(BP_Nouveau.activity_schedule)||(e=_.pick(BP_Nouveau.activity_schedule.params,["can_schedule_in_feed"]),t=_.extend(t,e)),this.model=new bp.Models.Activity(t),this.listenTo(Backbone,"mediaprivacy",this.updateMultiMediaOptions),this.listenTo(Backbone,"mediaprivacytoolbar",this.updateMultiMediaToolbar),this.listenTo(Backbone,"onError",this.onError),this.listenTo(Backbone,"cleanFeedBack",this.cleanFeedback),this.listenTo(Backbone,"triggerToastMessage",this.triggerToastMessage),"user"===BP_Nouveau.activity.params.object&&(BP_Nouveau.activity.params.access_control_settings.can_create_activity?this.$el.removeClass("bp-hide"):this.$el.addClass("bp-hide")),this.resetModel=this.model.clone(),this.views.set([new bp.Views.ActivityHeader({model:this.model}),new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.PrivacyStage({model:this.model}),new bp.Views.FormContent({activity:this.model,model:this.model}),new bp.Views.EditorToolbar({model:this.model}),new bp.Views.ActivityToolbar({model:this.model})]),this.model.on("change:errors",this.displayFeedback,this);var i=this;w(document).ready(function(e){w("#whats-new-form").closest("body").addClass("initial-post-form-open"),w("body").hasClass("initial-post-form-open")&&(i.displayFull(e),i.$el.closest(".activity-update-form").find("#aw-whats-new-reset").trigger("click")),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||!(!_.isUndefined(BP_Nouveau.media.emoji.profile)&&BP_Nouveau.media.emoji.profile||!_.isUndefined(BP_Nouveau.media.emoji.groups)&&BP_Nouveau.media.emoji.groups)||w("#whats-new").emojioneArea({standalone:!0,hideSource:!1,container:"#editor-toolbar > .post-emoji",autocomplete:!1,pickerPosition:"bottom",hidePickerOnBlur:!0,useInternalCDN:!1,events:{emojibtn_click:function(){if(w("#whats-new")[0].emojioneArea.hidePicker(),window.getSelection&&document.createRange){var e=window.getSelection();if(e&&0/gi,"\n").replace(/<\/div>/gi,""));""===(t=t.replace(/ /g," ")).replace(/

/gi,"").replace(/<\/p>/gi,"").replace(/
/gi,"")&&(e[0].innerHTML=""),""!==w(w.parseHTML(t)).text().trim()||t.includes('class="emoji"')||!_.isUndefined(this.model.get("link_success"))&&!0===this.model.get("link_success")||!_.isUndefined(this.model.get("video"))&&0!==this.model.get("video").length||!_.isUndefined(this.model.get("document"))&&0!==this.model.get("document").length||!_.isUndefined(this.model.get("media"))&&0!==this.model.get("media").length||!_.isUndefined(this.model.get("gif_data"))&&!_.isEmpty(this.model.get("gif_data"))?this.$el.removeClass("focus-in--empty"):this.$el.addClass("focus-in--empty")},mediumLink:function(){""!==w(".medium-editor-toolbar-input").val()&&w("#whats-new-form").removeClass("focus-in--empty")},displayFull:function(e){var t;6!==this.views._views[""].length&&w(this.views._views[""][6].$el).hasClass("updated")&&(this.cleanFeedback(),w("#whats-new-form").removeClass("bottom-notice")),6===this.views._views[""].length&&("focusin"===e.type&&w("#whats-new-form").closest("body").removeClass("initial-post-form-open").addClass(e.type+"-post-form-open"),this.model.on("change:video change:document change:media change:gif_data change:privacy, change:link_success",this.postValidate,this),t=this,_.each(this.views._views[""],function(e){"message-feedabck"!==e.$el.prop("id")||e.$el.hasClass("noMediaError")||(t.cleanFeedback(),t.$el.removeClass("has-feedback"))}),_.each(this.views._views[""],function(e,t){4

'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer"),_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(typeof BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed||w("#whats-new-form").find(".bb-schedule-post_dropdown_section").removeClass("bp-hide")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),null!==window.activityMediaAction&&(w(".activity-update-form.modal-popup").find("#"+window.activityMediaAction).trigger("click"),window.activityMediaAction=null),0===w(".activity-update-form .activity-update-form-overlay").length&&w(".activity-update-form.modal-popup").prepend('
'),this.activityHideModalEvent(),w("body").hasClass(e.type+"-post-form-open")&&!w("#whats-new-form").hasClass("bp-activity-edit")&&(bp.draft_local_interval||(bp.draft_local_interval=setInterval(function(){bp.Nouveau.Activity.postForm.storeDraftActivity()},3e3)),bp.draft_ajax_interval||(bp.draft_ajax_interval=setInterval(function(){bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)},2e4)),bp.Nouveau.Activity.postForm.displayDraftActivity()),w("a.bp-suggestions-mention:empty").remove())},activityHideModalEvent:function(){w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)})},triggerDisplayFull:function(e){var t,i;e.preventDefault(),(w(e.target).hasClass("toolbar-button")||w(e.target).parent().hasClass("toolbar-button"))&&(window.activityMediaAction=w(e.target).parent().attr("id"),void 0===window.activityMediaAction&&(window.activityMediaAction=w(e.target).attr("id"))),this.$el.hasClass("focus-in")||(t=this.$el.find("#whats-new")[0],i=window.getSelection(),(e=document.createRange()).setStart(t,0),e.setEnd(t,0),i.removeAllRanges(),i.addRange(e))},resetForm:function(){_.each(this.views._views[""],function(e,t){4/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");f.model.set("content",s,{silent:!0}),f.model.set(t,{silent:!0});var d=f.model.get("media");if("group"==f.model.get("object")&&!_.isUndefined(d)&&d.length){for(var n=0;n"+p+' '+u+"
","success",m,!0))),o?b&&"scheduled"!==g.activity_action_type&&w("#activity-"+e.id).length?(w("#activity-"+e.id).replaceWith(e.activity),c=e.activity.indexOf('data-bp-activity="')+'data-bp-activity="'.length,p=e.activity.indexOf('"',c),u=e.activity.substring(c,p),m=f.decodeHtml(u),l=JSON.parse(m),o=w("
").html(l.content).html(),l.content=o,p=(c=w("#activity-modal .activity-list .activity-item")).find(".activity-content").find(".activity-inner"),u=c.find(".bb-media-privacy-wrap").find(".privacy-wrap").find(".privacy"),m=c.find(".bb-media-privacy-wrap").find(".activity-privacy li"),0").addClass("activity-list item-list bp-list")),0
'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),bp.Nouveau.Activity.postForm.resetDraftActivity(!0)}}),bp.Views.PostFormPlaceholder=bp.View.extend({tagName:"form",className:"activity-form-placeholder",id:"whats-new-form-placeholder",initialize:function(){this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),this.resetModel=this.model.clone(),this.views.set([new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.FormPlaceholderContent({activity:this.model,model:this.model}),new bp.Views.ActivityToolbar({model:this.model})])}}),bp.Views.FormPlaceholderContent=bp.View.extend({tagName:"div",id:"whats-new-content-placeholder",initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea-placeholder")),this.views.set("#whats-new-textarea-placeholder",new bp.Views.WhatsNewPlaceholder)}}),bp.Views.WhatsNewPlaceholder=bp.View.extend({tagName:"div",className:"bp-suggestions-placehoder",id:"whats-new-placeholder",attributes:{name:"whats-new-placeholder",cols:"50",rows:"4",placeholder:BP_Nouveau.activity.strings.whatsnewPlaceholder,"aria-label":BP_Nouveau.activity.strings.whatsnewLabel,contenteditable:!0}}),bp.Views.PostGifProfile=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.profile)&&!1===BP_Nouveau.media.gif.profile||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Views.PostGifGroup=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.groups)&&!1===BP_Nouveau.media.gif.groups||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Nouveau.Activity.postForm.start())}((bp,jQuery)); \ No newline at end of file +window.wp=window.wp||{},window.bp=window.bp||{},function(w){bp.Nouveau=bp.Nouveau||{},void 0!==bp.Nouveau.Activity&&"undefined"!=typeof BP_Nouveau&&(_.extend(bp,_.pick(wp,"Backbone","ajax","template")),bp.Models=bp.Models||{},bp.Collections=bp.Collections||{},bp.Views=bp.Views||{},bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",bp.draft_ajax_request=null,bp.old_draft_data=!1,bp.draft_activity={object:!1,data_key:!1,data:!1,post_action:"update",allow_delete_media:!1,display_post:""},bp.draft_local_interval=!1,bp.draft_ajax_interval=!1,bp.draft_content_changed=!1,bp.Nouveau.Activity.postForm={start:function(){this.views=new Backbone.Collection,this.ActivityObjects=new bp.Collections.ActivityObjects,this.buttons=new Backbone.Collection,_.isUndefined(window.Dropzone)||_.isUndefined(BP_Nouveau.media)||this.dropzoneView(),this.postFormView(),this.postFormPlaceholderView(),this.getCurrentDraftActivity(),this.syncDraftActivity(),this.reloadWindow()},postFormView:function(){var e;this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),w("#bp-nouveau-activity-form").length&&(this.postForm=new bp.Views.PostForm,this.views.add({id:"post_form",view:this.postForm}),this.postForm.inject("#bp-nouveau-activity-form"),w(".activity-update-form #user-status-huddle, .activity-update-form #whats-new-content, .activity-update-form #whats-new-attachments").wrapAll('
'),e=this,w(document).on("click",".activity-update-form.modal-popup:not(.bp-activity-edit) .activity-update-form-overlay",function(){e.postForm.$el.hasClass("bp-activity-edit")||(bp.Nouveau.Activity.postForm.clearDraftInterval(),bp.Nouveau.Activity.postForm.collectDraftActivity(),bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)),setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)}),Backbone.trigger("mediaprivacy"))},postFormPlaceholderView:function(){w("#bp-nouveau-activity-form-placeholder").length&&(this.postFormPlaceholder=new bp.Views.PostFormPlaceholder,this.views.add({id:"post_form_placeholder",view:this.postFormPlaceholder}),this.postFormPlaceholder.inject("#bp-nouveau-activity-form-placeholder"),w(".activity-form-placeholder #user-status-huddle, .activity-form-placeholder #whats-new-content-placeholder").wrapAll('
'))},dropzoneView:function(){this.dropzone=null,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:_.isUndefined(BP_Nouveau.media.maxFiles)?10:BP_Nouveau.media.maxFiles,maxFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size,dictMaxFilesExceeded:BP_Nouveau.media.media_dict_file_exceeded,dictCancelUploadConfirmation:BP_Nouveau.media.dictCancelUploadConfirmation,maxThumbnailFilesize:_.isUndefined(BP_Nouveau.media.max_upload_size)?2:BP_Nouveau.media.max_upload_size},_.isUndefined(BP_Nouveau.media.dropzone_options)||Object.assign(this.dropzone_options,BP_Nouveau.media.dropzone_options)},displayEditActivity:function(t,i){bp.draft_activity.allow_delete_media=!0,bp.draft_activity.display_post="edit";var e=this;e.postForm.$el.trigger("reset"),e.editActivityData=t,this.model.set("edit_activity",!0),e.postForm.$el.addClass("bp-activity-edit").addClass("loading"),e.postForm.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),e.postForm.$el.removeClass("bp-hide"),e.postForm.$el.find("#whats-new-toolbar").addClass("hidden"),setTimeout(function(){var e=new Event("bp_activity_edit");bp.Nouveau.Activity.postForm.displayEditDraftActivityData(t,e,i)},0)},displayEditActivityForm:function(e,t){var i=w("#bp-nouveau-activity-form"),a=w("#bp-nouveau-activity-form-placeholder"),o=w("#bp-nouveau-single-activity-edit-form-wrap");o.length&&o.show(),bp.privacyEditable=e.can_edit_privacy,bp.album_id=e.album_id,bp.folder_id=e.folder_id,bp.group_id=e.group_id,bp.privacy=e.privacy,this.displayEditActivity(e,t),this.model.set("edit_activity",!0);e=w("#whats-new")[0],t=w("#whats-new-content")[0];window.activity_edit_editor=new window.MediumEditor(e,{placeholder:{text:"",hideOnClick:!0},toolbar:{buttons:["bold","italic","unorderedlist","orderedlist","quote","anchor","pre"],relativeContainer:t,static:!0,updateOnEmptySelection:!0},imageDragging:!1,anchor:{linkValidation:!0}}),window.activity_edit_editor.subscribe("editablePaste",function(t){setTimeout(function(){var e=w(t.target).find("li").filter(function(){return!w(this).parent().is("ul")&&!w(this).parent().is("ol")});0")},0)}),i.addClass("modal-popup").closest("body").addClass("activity-modal-open"),a.show(),setTimeout(function(){w("#whats-new img.emoji").each(function(e,t){w(t).addClass("emojioneemoji");var i=w(t).attr("alt");w(t).attr("data-emoji-char",i),w(t).removeClass("emoji")})},10),this.activityEditHideModalEvent()},activityEditHideModalEvent:function(){var e=this;w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&w(".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset").trigger("click")}),w(document).on("click",".activity-update-form.modal-popup.bp-activity-edit #aw-whats-new-reset",function(){e.postActivityEditHideModal()})},postActivityEditHideModal:function(){bp.privacyEditable=!0,bp.album_id=0,bp.folder_id=0,bp.group_id=0,bp.privacy="public",w(".activity-update-form.modal-popup").removeClass("modal-popup group-activity").closest("body").removeClass("activity-modal-open");var e=w("#bp-nouveau-activity-form-placeholder"),t=w("#bp-nouveau-single-activity-edit-form-wrap"),i=w("#bp-nouveau-activity-form");w("#whats-new-content").parent().is(".edit-activity-content-wrap")&&w("#whats-new-content").unwrap(),e.hide(),t.length&&t.hide(),i.hasClass("is-bp-hide")&&i.addClass("bp-hide"),bp.Views.ActivityHeader.prototype.resetMultiMediaOptions()},createThumbnailFromUrl:function(t){var i=this;i.dropzone.createThumbnailFromUrl(t,i.dropzone.options.thumbnailWidth,i.dropzone.options.thumbnailHeight,i.dropzone.options.thumbnailMethod,!0,function(e){i.dropzone.emit("thumbnail",t,e),i.dropzone.emit("complete",t)})},displayEditDraftActivityData:function(e,t,i){var a=this;a.postForm.$el.parent("#bp-nouveau-activity-form").removeClass("bp-hide"),a.postForm.$el.find("#whats-new").html(e.content),null!=i&&a.postForm.$el.find("#whats-new").data("activity-url-preview",i);var o,s=a.postForm.$el.find("#whats-new").get(0);s.focus(),0')),bp.privacyEditable||"groups"===e.object?a.postForm.$el.removeClass("bp-activity-edit--privacy-idle"):a.postForm.$el.addClass("bp-activity-edit--privacy-idle"),0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");e.postForm.model.set("content",i,{silent:!0}),e.postForm.model.set(t,{silent:!0});var a=e.postForm.model.get("media");if("group"===e.postForm.model.get("object")&&!_.isUndefined(a)&&a.length){for(var o=0;o"+BP_Nouveau.media.invalid_media_type+". "+t.data.feedback+"
"),this.removeFile(e);bp.draft_content_changed=!0}),bp.Nouveau.Activity.postForm.dropzone.on("error",function(e,t){e.accepted?_.isUndefined(t)||_.isUndefined(t.data)||_.isUndefined(t.data.feedback)?"error"==e.status&&e.xhr&&0==e.xhr.status&&w(e.previewElement).find(".dz-error-message span").text(BP_Nouveau.media.connection_lost_error):w(e.previewElement).find(".dz-error-message span").text(t.data.feedback):(Backbone.trigger("onError","
"+BP_Nouveau.media.invalid_media_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.media.length){for(var t in l.media){var i;e.id===l.media[t].id?(_.isUndefined(l.media[t].saved)||l.media[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.media.splice(t,1),l.model.set("media",l.media)):"edit"===bp.draft_activity.display_post||!e.media_edit_data||(i=e.media_edit_data.id)===l.media[t].id&&(l.media.splice(t,1),l.model.set("media",l.media),bp.Nouveau.Media.removeAttachment(i))}var a=l.$el.find(".dz-preview.dz-error").length;l.media.length===a&&l.model.unset("media")}_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),a.find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("no-click"),l.model.unset("media"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0"+BP_Nouveau.media.invalid_file_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.document.length)for(var t in l.document){var i;e.id===l.document[t].id?(_.isUndefined(l.document[t].saved)||l.document[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.document.splice(t,1),l.model.set("document",l.document)):"edit"===bp.draft_activity.display_post||!e.document_edit_data||(i=e.document_edit_data.id)===l.document[t].id&&(l.document.splice(t,1),l.model.set("document",l.document),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-video-button")&&a.find("#activity-video-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable no-click"),l.model.unset("document"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(e){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0'),w(e.previewElement).closest(".dz-preview").addClass("dz-has-thumbnail")):bp.Nouveau.getVideoThumb&&bp.Nouveau.getVideoThumb(e,".dz-video-thumbnail")}),bp.Nouveau.Activity.postForm.dropzone.on("sending",function(e,t,i){i.append("action","video_upload"),i.append("_wpnonce",BP_Nouveau.nonces.video);i=l.$el.parents("#whats-new-form");i.find("#activity-media-button")&&i.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-gif-button")&&i.find("#activity-gif-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-document-button")&&i.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),i.find("#activity-video-button")&&i.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("no-click")}),bp.Nouveau.Activity.postForm.dropzone.on("uploadprogress",function(e){l.$el.closest("#whats-new-form").addClass("media-uploading");var t=w(e.previewElement).find(".dz-progress-ring circle")[0],i=2*t.r.baseVal.value*Math.PI;t.style.strokeDasharray=i+" "+i;var a=i-e.upload.progress.toFixed(0)/100*i;e.upload.progress<=99?(w(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,w(e.previewElement).find(".dz-progress-count").text("99% "+BP_Nouveau.video.i18n_strings.video_uploaded_text))}),bp.Nouveau.Activity.postForm.dropzone.on("success",function(e,t){if(100===e.upload.progress&&(w(e.previewElement).find(".dz-progress-ring circle")[0].style.strokeDashoffset=0,w(e.previewElement).find(".dz-progress-count").text("100% "+BP_Nouveau.video.i18n_strings.video_uploaded_text),w(e.previewElement).closest(".dz-preview").addClass("dz-complete")),!t.data.id){var i,a,o,s,d,n=t.data.feedback;for(e.previewElement.classList.add("dz-error"),d=[],a=0,o=(s=e.previewElement.querySelectorAll("[data-dz-errormessage]")).length;a"+BP_Nouveau.video.invalid_video_type+". "+(t||"")+"
"),this.removeFile(e),l.$el.closest("#whats-new-form").removeClass("media-uploading"))}),bp.Nouveau.Activity.postForm.dropzone.on("removedfile",function(e){if(!0===bp.draft_activity.allow_delete_media){if(l.video.length)for(var t in l.video){var i;e.id===l.video[t].id?(_.isUndefined(l.video[t].saved)||l.video[t].saved||bp.Nouveau.Media.removeAttachment(e.id),l.video.splice(t,1),l.model.set("video",l.video)):"edit"===bp.draft_activity.display_post||!e.video_edit_data||(i=e.video_edit_data.id)===l.video[t].id&&(l.video.splice(t,1),l.model.set("video",l.video),bp.Nouveau.Media.removeAttachment(i))}var a;_.isNull(bp.Nouveau.Activity.postForm.dropzone.files)||0!==bp.Nouveau.Activity.postForm.dropzone.files.length||(l.$el.closest("#whats-new-form").removeClass("media-uploading"),(a=l.$el.parents("#whats-new-form")).find("#activity-media-button")&&a.find("#activity-media-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-gif-button")&&a.find("#activity-gif-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),a.find("#activity-document-button")&&a.find("#activity-document-button").parents(".post-elements-buttons-item").removeClass("disable active no-click"),l.model.unset("video"),w("#message-feedabck").hasClass("noMediaError")&&l.model.unset("errors")),bp.draft_content_changed=!0}}),bp.Nouveau.Activity.postForm.dropzone.on("complete",function(){0===this.getUploadingFiles().length&&0===this.getQueuedFiles().length&&0/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," "),""!==a.find(".ac-textarea").children(".ac-input").text().trim()||0<=i.indexOf("emojioneemoji")?w(a).closest("form").addClass("has-content"):w(a).closest("form").removeClass("has-content")),_.isUndefined(e)||_.isEmpty(t)||!_.isEmpty(this.model.get("gif_data"))||(bp.draft_content_changed=!0)}}),bp.Views.GifMediaSearchDropdown=bp.View.extend({tagName:"div",className:"activity-attached-gif-container",template:bp.template("gif-media-search-dropdown"),total_count:0,offset:0,limit:20,q:null,requests:[],standalone:!1,events:{"keydown .search-query-input":"search","click .found-media-item":"select"},initialize:function(e){this.select=this.select.bind(this),e&&void 0!==e.standalone&&(this.standalone=e.standalone),this.options=e||{},this.giphy=new window.Giphy(BP_Nouveau.media.gif_api_key),this.gifDataItems=new bp.Collections.GifDatas,this.listenTo(this.gifDataItems,"add",this.addOne),this.listenTo(this.gifDataItems,"reset",this.addAll),document.addEventListener("scroll",_.bind(this.loadMore,this),!0)},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.$gifResultItem=this.$el.find(".gif-search-results-list"),this.loadTrending(),this},search:function(e){if("Enter"===e.key||13===e.keyCode)return e.preventDefault(),!1;var t=this;null!=this.Timeout&&clearTimeout(this.Timeout),""!==e.target.value?this.Timeout=setTimeout(function(){this.Timeout=null,t.searchGif(e.target.value)},1e3):this.loadTrending()},searchGif:function(e){var t=this;t.q=e,t.offset=0,t.clearRequests(),t.el.classList.add("loading"),this.$el.find(".gif-no-results").removeClass("show"),this.$el.find(".gif-no-connection").removeClass("show");e=t.giphy.search({q:e,offset:t.offset,fmt:"json",limit:this.limit},function(e){void 0!==e.data.length&&0===e.data.length&&w(t.el).find(".gif-no-results").addClass("show"),void 0!==e.meta.status&&200!==e.meta.status&&w(t.el).find(".gif-no-connection").addClass("show"),t.gifDataItems.reset(e.data),t.total_count=e.pagination.total_count,t.el.classList.remove("loading")},function(){w(t.el).find(".gif-no-connection").addClass("show")});t.requests.push(e),t.offset=t.offset+t.limit},select:function(e){e.preventDefault(),this.$el.parent().removeClass("open");var t=this.gifDataItems.findWhere({id:e.currentTarget.dataset.id});this.model.set("gif_data",t.attributes);t=this.$el.parents("#whats-new-form");t.find("#activity-document-button")&&t.find("#activity-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-media-button")&&t.find("#activity-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find("#activity-video-button")&&t.find("#activity-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.parents(".ac-reply-content");t.find(".ac-reply-toolbar .ac-reply-media-button")&&t.find(".ac-reply-toolbar .ac-reply-media-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-document-button")&&t.find(".ac-reply-toolbar .ac-reply-document-button").parents(".post-elements-buttons-item").addClass("disable"),t.find(".ac-reply-toolbar .ac-reply-video-button")&&t.find(".ac-reply-toolbar .ac-reply-video-button").parents(".post-elements-buttons-item").addClass("disable");t=this.$el.closest("#whats-new-form");(this.standalone?this.$el.closest(".screen-content, .elementor-widget-container, .buddypress-wrap").find("#activity-modal .ac-form"):this.$el.closest(".ac-form")).addClass("has-gif");t=t.find(".whats-new-scroll-view");0=i.scrollHeight&&!i.classList.contains("loading")&&0/g,""):e).indexOf("http://")?i=this.getURL("http://",e):0<=e.indexOf("https://")?i=this.getURL("https://",e):0<=e.indexOf("www.")&&(i=this.getURL("www",e)),""!==i&&((e=document.createElement("a")).href=i,e=e.hostname,-1!==BP_Nouveau.activity.params.excluded_hosts.indexOf(e)&&(i="")),""!==i?this.loadURLPreview(i):void 0!==a&&this.loadURLPreview(a))},getURL:function(e,t){var i="",a=(t=t.replace(/ /g,"")).indexOf(e),o="";if(_.isUndefined(w(w.parseHTML(t)).attr("href"))){for(var s=a;s"===t[s+1]||"<"===t[s]&&"b"===t[s+1]&&"r"===t[s+2]);s++)i+=t[s];"www"===e&&(i=(e="http://")+i)}else i=w(t).attr("href");e=document.createElement("div");e.innerHTML=i;for(var d=e.getElementsByTagName("*");d[0];)d[0].parentNode.removeChild(d[0]);return o=0")},0)}))}),w(document).on("keyup",".activity-form .medium-editor-toolbar-input",function(e){var t=e.target.value;bp.Nouveau.isURL(t)?w(e.target).removeClass("isNotValid").addClass("isValid"):w(e.target).removeClass("isValid").addClass("isNotValid")}),e=bp.Nouveau.getLinkParams(null,"r")||null,_.isNull(e)||w("#message_content").focus())}}),bp.Views.WhatsNewPostIn=bp.View.extend({tagName:"select",id:"whats-new-post-in",attributes:{name:"whats-new-post-in","aria-label":BP_Nouveau.activity.strings.whatsnewpostinLabel},events:{change:"change"},keys:[],initialize:function(){this.model=new Backbone.Model,this.filters=this.options.filters||{},this.$el.html(_.chain(this.filters).map(function(e,t){return{el:w("").val(t).html(e.text)[0],priority:e.priority||50}},this).sortBy("priority").pluck("el").value())},change:function(){var e=this.filters[this.el.value];e&&this.model.set({selected:this.el.value,placeholder:e.autocomplete_placeholder})}}),bp.Views.ActivityPrivacy=bp.View.extend({tagName:"div",id:"activity-post-form-privacy",template:bp.template("activity-post-form-privacy"),initialize:function(){this.model=new bp.Models.Activity}}),bp.Views.Item=bp.View.extend({tagName:"div",className:"bp-activity-object",template:bp.template("activity-target-item"),initialize:function(){this.model.get("selected")&&(this.el.className+=" selected")},events:{click:"setObject"},setObject:function(e){e.preventDefault();e=w("#whats-new-form");!0===this.model.get("selected")&&this.model.unset("selected"),e.removeClass("focus-in--blank-group");var t=this;t.model.hasOwnProperty("attributes")&&t.model.attributes.hasOwnProperty("object_type")&&"group"===t.model.attributes.object_type&&((i=_.find(this.model.collection.models,function(e){return e!==t.model&&e.get("selected")}))&&i.set("selected",!1)),this.model.set("selected",!0);var i=this.model.attributes;void 0!==i.group_media&&!1===i.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),void 0!==i.group_document&&!1===i.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),void 0!==i.group_video&&!1===i.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide")}}),bp.Views.AutoComplete=bp.View.extend({tagName:"div",id:"whats-new-post-in-box-items",ac_req:!1,events:{keyup:"autoComplete"},initialize:function(){var e,t,i,a,o=new bp.Views.ActivityInput({type:"text",id:"activity-autocomplete",placeholder:this.options.placeholder||""}).render();this.$el.html(o.$el),o.$el.wrapAll('').after(''),this.$el.append('
'),this.on("ready",this.setFocus,this),"group"===this.options.type&&((o=BP_Nouveau.activity.params.objects.group_list)&&(this.collection.add(o),_.each(this.collection.models,function(e){this.addItemView(e)},this)),e=BP_Nouveau.activity.params.objects.group_total_page,o=BP_Nouveau.activity.params.objects.group_count,1this.collection.models.length&&((t=this).$el.find("#bp-activity-group-ac-items").addClass("group_scrolling load_more_data"),i=this.$el.find("#bp-activity-group-ac-items"),a=1,i.on("scroll",function(){if(window.acScrollPosition=i.scrollTop(),t.$el.find("#bp-activity-group-ac-items").hasClass("load_more_data")){if(e<++a)return t.$el.find("#bp-activity-group-ac-items").removeClass("load_more_data"),!(a=1);t.loadMoreData(t,a)}}))),this.collection.on("add",this.addItemView,this),this.collection.on("reset",this.cleanView,this)},setFocus:function(){var e;this.$el.find("#activity-autocomplete").focus(),w("#bp-activity-group-ac-items .bp-activity-object").length&&(e=w("#bp-activity-group-ac-items"),w(".bp-activity-object").each(function(){w(this).hasClass("selected")&&(e.scrollTop(window.acScrollPosition),e.on("scroll",function(){window.acScrollPosition=w(this).scrollTop()}))}))},addItemView:function(e){e=new bp.Views.Item({model:e});this.$el.find("#bp-activity-group-ac-items").append(e.render().$el)},autoComplete:function(){var e=this,t=w("#activity-autocomplete").val(),i=e.$el.closest("#whats-new-form");0===parseInt(t.length)?(this.autoCompleteCollectionData(e,t),e.$el.find("#bp-activity-group-ac-items").addClass("load_more_data"),e.$el.removeClass("activity-is-autocomplete"),i.addClass("focus-in--blank-group")):(e.$el.addClass("activity-is-autocomplete"),w("#whats-new-post-in-box-items .activity-autocomplete-clear").on("click",function(){w("#activity-autocomplete").val("").keyup(),i.addClass("focus-in--blank-group")})),t.length<2||this.autoCompleteCollectionData(e,t)},autoCompleteCollectionData:function(e,t){this.collection.reset(),this.ac_req&&this.ac_req.abort(),"group"===this.options.type?(this.$el.find("#bp-activity-group-ac-items").html('
'+BP_Nouveau.activity.params.objects.group.finding_group_placeholder+"
"),this.$el.find("#bp-activity-group-ac-items").addClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").html('');var i={type:this.options.type,nonce:BP_Nouveau.nonces.activity};""!==t&&(i.search=t),this.ac_req=this.collection.fetch({data:i,success:_.bind(this.itemFetched,this,e.options.type),error:_.bind(this.itemFetched,this,e.options.type)})},itemFetched:function(e,t){t.length||this.cleanView(e),"group"===e?(this.$el.find("#bp-activity-group-ac-items").find(".groups-selection--finding").remove(),this.$el.find("#bp-activity-group-ac-items").removeClass("group_scrolling--revive")):this.$el.find("#bp-activity-group-ac-items").find("i.dashicons").remove()},cleanView:function(e){"group"===e?this.$el.find("#bp-activity-group-ac-items").html(''+BP_Nouveau.activity.params.objects.group.no_groups_found+""):this.$el.find("#bp-activity-group-ac-items").html(""),_.each(this.views._views[""],function(e){e.remove()})},loadMoreData:function(i,e){this.$el.find("#bp-activity-group-ac-items .groups-selection--loading").length||this.$el.find("#bp-activity-group-ac-items .bp-activity-object:last").after('
'+BP_Nouveau.activity.params.objects.group.loading_group_placeholder+"
");var a=!1;return(new bp.Collections.fetchCollection).fetch({type:"POST",data:{type:i.options.type,nonce:BP_Nouveau.nonces.activity,page:e,action:"bp_nouveau_get_activity_objects"},success:function(e,t){!0===t.success&&(i.collection.add(t.data),w("#bp-activity-group-ac-items .groups-selection--loading").remove(),a=!0)}}),a}}),bp.Views.UserStatusHuddle=bp.View.extend({tagName:"div",id:"user-status-huddle",className:"bp-activity-huddle",initialize:function(){this.views.add(new bp.Views.CaseAvatar({model:this.model})),this.views.add(new bp.Views.CaseHeading({model:this.model})),this.views.add(new bp.Views.CasePrivacy({model:this.model})),void 0!==bp.Views.PostScheduleTime&&this.views.add(new bp.Views.PostScheduleTime({model:this.model})),w("#whats-new-heading, #whats-new-status").wrapAll('
'),setTimeout(function(){w(".activity-singular #whats-new-heading, .activity-singular #whats-new-status, .activity-singular #activity-schedule-section").wrapAll('
')},1e3)}}),bp.Views.CaseAvatar=bp.View.extend({tagName:"div",id:"whats-new-avatar",template:bp.template("activity-post-case-avatar"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CaseHeading=bp.View.extend({tagName:"div",id:"whats-new-heading",template:bp.template("activity-post-case-heading"),initialize:function(){this.model=new Backbone.Model(_.pick(BP_Nouveau.activity.params,["user_id","avatar_url","avatar_width","avatar_height","avatar_alt","user_domain","user_display_name"])),this.model.has("avatar_url")&&this.model.set("display_avatar",!0)}}),bp.Views.CasePrivacy=bp.View.extend({tagName:"div",id:"whats-new-status",template:bp.template("activity-post-case-privacy"),events:{"click #bp-activity-privacy-point":"privacyTarget"},initialize:function(){this.listenTo(Backbone,"privacy:updatestatus",this.updateStatus),this.model.on("change:privacy",this.render,this)},render:function(){var e;return this.$el.html(this.template(this.model.toJSON())),_.isUndefined(BP_Nouveau.activity.params.object)||"group"!==BP_Nouveau.activity.params.object||"group"!==BP_Nouveau.activity.params.object||(this.model.set("item_name",BP_Nouveau.activity.params.item_name),this.model.set("privacy","group"),e=BP_Nouveau.activity.params.item_name,w("#whats-new-form").find(".bp-activity-privacy-status").text(e),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),BP_Nouveau.activity.params.group_avatar&&!1===BP_Nouveau.activity.params.group_avatar.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),bp.draft_activity.data.item_id=BP_Nouveau.activity.params.item_id,bp.draft_activity.data.group_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.group_image=BP_Nouveau.activity.params.group_avatar,bp.draft_activity.data.item_name=BP_Nouveau.activity.params.item_name,bp.draft_activity.data.privacy="group",bp.draft_activity.data["group-privacy"]="bp-item-opt-"+BP_Nouveau.activity.params.item_id,localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity))),!_.isUndefined(bp.draft_activity)&&""!==bp.draft_activity.object&&"group"===bp.draft_activity.object&&bp.draft_activity.data&&""!==bp.draft_activity.data&&(this.model.set("item_name",bp.draft_activity.data.item_name),this.model.set("privacy","group"),w("#whats-new-form").find(".bp-activity-privacy-status").text(bp.draft_activity.data.item_name),this.$el.find("#bp-activity-privacy-point").removeClass().addClass("group bp-activity-focus-group-active"),bp.draft_activity.data.group_image&&!1===bp.draft_activity.data.group_image.includes("mystery-group")?this.$el.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon").html(''):(this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),this.$el.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"))),this},updateStatus:function(){this.model.get("privacy")},privacyTarget:function(e){if(this.$el.find("#bp-activity-privacy-point").hasClass("bp-activity-edit-group")||!_.isUndefined(BP_Nouveau.activity.params.object)&&"group"===BP_Nouveau.activity.params.object||!bp.privacyEditable)return!1;e.preventDefault(),w("#activity-post-form-privacy").show(),w("#whats-new-form").addClass("focus-in--privacy"),Backbone.trigger("privacy:headerupdate"),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.closest("#whats-new-form").find(".bp-activity-privacy__input:checked").val())}}),bp.Views.PrivacyStage=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage",className:"bp-activity-privacy-stage",events:{"click #privacy-status-submit":"privacyStatusSubmit","click #privacy-status-back":"backPrivacySelector","click #privacy-status-group-back":"backGroupSelector","click input.bp-activity-privacy__input":"privacySelector"},initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.PrivacyStageBody({model:this.model}),this.views.add(e)),this.views.add(new bp.Views.PrivacyStageFooter({model:this.model}))},privacyStatusSubmit:function(e){e.preventDefault();var t=this.$el.find(".bp-activity-privacy__input:checked").val();this.model.set("privacy",t),this.model.set("privacy_modal","general"),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}));var i=w("#whats-new-form");i.removeClass("focus-in--privacy focus-in--group"),Backbone.trigger("privacy:updatestatus");var a,e=this.model.attributes.item_id;"group"===t?(a=i.find("#bp-item-opt-"+e).data("title"),i.find(".bp-activity-privacy-status").text(a),i.find("#bp-activity-privacy-point").removeClass().addClass(t),this.model.set("item_name",a),this.model.set("group_name",a),this.model.attributes.group_image&&!1===this.model.attributes.group_image.includes("mystery-group")?(i.find("#bp-activity-privacy-point span.privacy-point-icon").removeClass("privacy-point-icon").addClass("group-privacy-point-icon"),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").html('')):(i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon")),_.isUndefined(BP_Nouveau.media)||(bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model})),a=i.find("#bp-item-opt-"+e).data("allow-schedule-post"),_.isUndefined(a)||"enabled"!==a?"scheduled"===this.model.attributes.activity_action_type?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide"),Backbone.trigger("onError",BP_Nouveau.activity_schedule.strings.notAllowScheduleWarning,"error")):(this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):(this.model.set("schedule_allowed",a),i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"))):(_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed?(this.model.set("activity_action_type",null),this.model.set("activity_schedule_date_raw",null),this.model.set("activity_schedule_date",null),this.model.set("activity_schedule_time",null),this.model.set("activity_schedule_meridiem",null),this.model.set("schedule_allowed","disabled"),i.find(".bb-schedule-post_dropdown_section").addClass("bp-hide")):i.find(".bb-schedule-post_dropdown_section").removeClass("bp-hide"),Backbone.trigger("cleanFeedBack"),e=this.model.attributes.privacy,a=i.find("#"+e).data("title"),i.find("#bp-activity-privacy-point").removeClass().addClass(e),i.find(".bp-activity-privacy-status").text(a),i.find(".bp-activity-privacy__input#"+e).prop("checked",!0),i.find("#bp-activity-privacy-point span.group-privacy-point-icon img").remove(),i.find("#bp-activity-privacy-point span.group-privacy-point-icon").removeClass("group-privacy-point-icon").addClass("privacy-point-icon"),this.model.set("item_id",0),this.model.set("item_name",""),this.model.set("group_name",""),this.model.set("group_image",""),this.model.set("group-privacy",""),bp.draft_activity.data.item_id=0,bp.draft_activity.data.group_name="",bp.draft_activity.data.group_image="",bp.draft_activity.data.item_name="",bp.draft_activity.data.privacy=e,bp.draft_activity.data["group-privacy"]="",localStorage.setItem(bp.draft_activity.data_key,JSON.stringify(bp.draft_activity)))},backPrivacySelector:function(e){e.preventDefault();e=this.model.get("privacy");w("#whats-new-form").removeClass("focus-in--privacy focus-in--group"),this.model.set("privacy_modal","general"),this.$el.find("input#"+e).prop("checked",!0),w("#whats-new-form").hasClass("bp-activity-edit")&&this.model.set("privacy",this.$el.find(".bp-activity-privacy__input:checked").val())},backGroupSelector:function(e){e.preventDefault();var t=w("#whats-new-form");this.model.set("privacy_modal","profile"),t.removeClass("focus-in--group");e=this.model.get("privacy");this.$el.find("input#"+e).prop("checked",!0),w("#activity-post-form-privacy").show(),t.removeClass("focus-in--blank-group")},privacySelector:function(e){var t=w("#whats-new-form");"group"===w(e.currentTarget).val()?(w(e.currentTarget).closest("#whats-new-privacy-stage").find("#whats-new-post-in").val("group").trigger("change"),t.addClass("focus-in--group"),this.model.set("privacy_modal","group"),this.model.set("object",w(e.currentTarget).val()),w("#activity-post-form-privacy").hide(),0===this.model.attributes.item_id&&t.addClass("focus-in--blank-group")):(w("#privacy-status-submit").click(),this.model.set("object","user"),Backbone.trigger("mediaprivacytoolbar"))}}),bp.Views.PrivacyStageBody=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-body",className:"privacy-status-form-body",initialize:function(){var e;(!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length||!_.isUndefined(BP_Nouveau.activity.params.object)&&"user"===BP_Nouveau.activity.params.object)&&(e=new bp.Views.ActivityPrivacy({model:this.model}),this.views.add(e)),_.isUndefined(BP_Nouveau.activity.params.objects)&&"user"===BP_Nouveau.activity.params.object&&this.$el.find(".bp-activity-privacy__label-group").hide().find("input#group").attr("disabled",!0),!_.isUndefined(BP_Nouveau.activity.params.objects)&&1<_.keys(BP_Nouveau.activity.params.objects).length&&(!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData))?this.views.add(new bp.Views.FormTarget({model:this.model})):!1===bp.Nouveau.Activity.postForm.editActivityData||_.isUndefined(bp.Nouveau.Activity.postForm.editActivityData)||this.views.add(new bp.Views.EditActivityPostIn({model:this.model}))}}),bp.Views.PrivacyStageFooter=bp.View.extend({tagName:"div",id:"whats-new-privacy-stage-footer",className:"privacy-status-form-footer",template:bp.template("activity-post-privacy-stage-footer")}),bp.Views.FormContent=bp.View.extend({tagName:"div",id:"whats-new-content",events:{"click .medium-editor-toolbar-actions":"focusEditor","input #whats-new":"focusEditorOnChange","click .medium-editor-toolbar li.close-btn":"hideToolbarSelector"},initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea")),this.$el.append(''),this.views.set("#whats-new-textarea",new bp.Views.WhatsNew({activity:this.options.activity}))},hideToolbarSelector:function(e){e.preventDefault(),w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar").removeClass("active")},focusEditor:function(e){null===window.activity_editor.exportSelection()&&w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus(),e.preventDefault()},focusEditorOnChange:function(e){var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");setTimeout(function(){t.addClass("medium-editor-toolbar-active"),w(e.currentTarget).closest("#whats-new-form").find("#whats-new-textarea > div").focus()},0)}}),bp.Views.FormOptions=bp.View.extend({tagName:"div",id:"whats-new-options",template:bp.template("activity-post-form-options")}),bp.Views.FormTarget=bp.View.extend({tagName:"div",id:"whats-new-post-in-box",className:"in-profile",initialize:function(){var e=new bp.Views.WhatsNewPostIn({filters:BP_Nouveau.activity.params.objects});this.views.add(e),e.model.on("change",this.attachAutocomplete,this),bp.Nouveau.Activity.postForm.ActivityObjects.on("change:selected",this.postIn,this),this.toggleMultiMediaOptions()},attachAutocomplete:function(e){0!==bp.Nouveau.Activity.postForm.ActivityObjects.models.length&&bp.Nouveau.Activity.postForm.ActivityObjects.reset(),_.each(this.views._views[""],function(e){_.isUndefined(e.collection)||e.remove()}),"profile"!==e.get("selected")?(this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:e.get("selected"),placeholder:e.get("placeholder")})),this.model.set("object",e.get("selected"))):this.model.set({object:"user",item_id:0}),this.updateDisplay(),this.toggleMultiMediaOptions()},postIn:function(e){if(_.isUndefined(e.get("id")))return this.model.set("item_id",0),void this.attachAutocomplete(new Backbone.Model({selected:this.model.get("object")}));this.model.set("item_id",e.get("id")),"group"===this.model.get("object")?(this.views.remove("#whats-new-post-in-box-items"),this.views.add(new bp.Views.AutoComplete({collection:bp.Nouveau.Activity.postForm.ActivityObjects,type:this.model.get("object"),placeholder:BP_Nouveau.activity.params.objects.group.autocomplete_placeholder})),this.model.set("object",this.model.get("object")),this.model.set("group_name",e.get("name")),this.model.set("item_name",e.get("name")),this.model.set("group_image",e.get("avatar_url")),this.model.set("group_url",e.get("group_url"))):this.views.set("#whats-new-post-in-box-items",new bp.Views.Item({model:e}))},updateDisplay:function(){"user"!==this.model.get("object")?(this.$el.removeClass(),w("#activity-post-form-privacy").hide()):this.$el.hasClass("in-profile")||(this.$el.addClass("in-profile"),w("#activity-post-form-privacy").show())},toggleMultiMediaOptions:function(){_.isUndefined(BP_Nouveau.media)||("user"!==this.model.get("object")?(!1===BP_Nouveau.media.group_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.group_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.group_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifGroup=new bp.Views.PostGifGroup({model:this.model}),!1===BP_Nouveau.media.emoji.groups?(w("#whats-new-textarea").find("img.emojioneemoji").remove(),w("#editor-toolbar .post-emoji").addClass("post-emoji-hide")):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")):(!1===BP_Nouveau.media.profile_media?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-media-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.media-support").removeClass("active").addClass("media-support-hide"),Backbone.trigger("activity_media_close")):w("#whats-new-toolbar .post-media.media-support").removeClass("media-support-hide"),!1===BP_Nouveau.media.profile_document?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-document-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-media.document-support").removeClass("active").addClass("document-support-hide"),Backbone.trigger("activity_document_close")):w("#whats-new-toolbar .post-media.document-support").removeClass("document-support-hide"),!1===BP_Nouveau.video.profile_video?void 0!==bp.Nouveau.Activity.postForm.dropzone&&null!==bp.Nouveau.Activity.postForm.dropzone&&"activity-post-video-uploader"!==bp.Nouveau.Activity.postForm.dropzone.element.id||(w("#whats-new-toolbar .post-video.video-support").removeClass("active").addClass("video-support-hide"),Backbone.trigger("activity_video_close")):w("#whats-new-toolbar .post-video.video-support").removeClass("video-support-hide"),bp.Nouveau.Activity.postForm.postGifProfile=new bp.Views.PostGifProfile({model:this.model}),!1===BP_Nouveau.media.emoji.profile?(w("#editor-toolbar .post-emoji").addClass("post-emoji-hide"),w("#whats-new-textarea").find("img.emojioneemoji").remove()):w("#editor-toolbar .post-emoji").removeClass("post-emoji-hide")),w(".medium-editor-toolbar").removeClass("active medium-editor-toolbar-active"),w("#show-toolbar-button").removeClass("active"),w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip",w("#show-toolbar-button").parent(".show-toolbar").attr("data-bp-tooltip-show")))}}),bp.Views.EditorToolbar=bp.View.extend({tagName:"div",id:"editor-toolbar",template:bp.template("editor-toolbar"),events:{"click .show-toolbar":"toggleToolbarSelector","click .post-mention":"triggerMention"},toggleToolbarSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest("#whats-new-form").find(".medium-editor-toolbar");t.hasClass("active")||bp.Nouveau.mediumEditorButtonsWarp(t),w(e.currentTarget).find(".toolbar-button").toggleClass("active"),w(e.currentTarget).find(".toolbar-button").hasClass("active")?(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-hide")),null!=window.activity_editor.exportSelection()&&t.addClass("medium-editor-toolbar-active")):(w(e.currentTarget).attr("data-bp-tooltip",jQuery(e.currentTarget).attr("data-bp-tooltip-show")),null===window.activity_editor.exportSelection()&&t.removeClass("medium-editor-toolbar-active"),t.find("li.medium-editor-action-more").removeClass("active")),w(window.activity_editor.elements[0]).focus(),t.toggleClass("medium-editor-toolbar-active active")},triggerMention:function(e){e.preventDefault();var a=this.$el,o=a.closest(".activity-update-form").find("#whats-new"),s=a.closest(".whats-new-scroll-view").scrollTop();setTimeout(function(){var e;o.focus(),window.activityCaretPosition&&(window.getSelection&&document.createRange?((t=document.createRange()).setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),t.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),(e=window.getSelection()).removeAllRanges(),e.addRange(t)):((i=document.body.createTextRange()).moveToElementText(o[0]),i.setStart(window.activityCaretPosition.startContainer,window.activityCaretPosition.startOffset),i.setEnd(window.activityCaretPosition.endContainer,window.activityCaretPosition.endOffset),i.select()));var t=window.getSelection().getRangeAt(0).cloneRange();t.collapse(!0),t.setStart(o[0],0);var i=t.toString().slice(-1);w(t.endContainer.parentElement).hasClass("atwho-inserted")||(""===i.trim()?document.execCommand("insertText",!1,"@"):"@"!==i&&document.execCommand("insertText",!1," @")),o.trigger("keyup"),setTimeout(function(){o.trigger("keyup"),a.closest(".whats-new-scroll-view").scrollTop(s)},0)},0)}}),bp.Views.ActivityToolbar=bp.View.extend({tagName:"div",id:"whats-new-toolbar",template:bp.template("whats-new-toolbar"),events:{"click .post-elements-buttons-item.disable .toolbar-button":"disabledButton","click #activity-link-preview-button":"toggleURLInput","click #activity-gif-button":"toggleGifSelector","click #activity-media-button":"toggleMediaSelector","click #activity-document-button":"toggleDocumentSelector","click #activity-video-button":"toggleVideoSelector","click .post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )":"activeButton","click .post-elements-buttons-item.post-gif:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-media:not(.disable)":"activeMediaButton","click .post-elements-buttons-item.post-video:not(.disable)":"activeVideoButton","click .post-elements-buttons-item:not(.post-gif):not(.active)":"scrollToMedia"},gifMediaSearchDropdownView:!1,initialize:function(){document.addEventListener("keydown",_.bind(this.closePickersOnEsc,this)),w(document).on("click",_.bind(this.closePickersOnClick,this))},render:function(){return this.$el.html(this.template(this.model.attributes)),this.$self=this.$el.find("#activity-gif-button"),this.$gifPickerEl=this.$el.find(".gif-media-search-dropdown"),this.$emojiPickerEl=w("#whats-new"),this.$el.removeClass("hidden"),setTimeout(function(){var e=w(".activity-form #whats-new-toolbar");e&&(0===e.children(":visible").length?e.addClass("hidden"):e.removeClass("hidden"))},0),this},toggleURLInput:function(e){e.preventDefault(),this.closeMediaSelector(),this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),e=this.model.get("link_scrapping")?new Event("activity_link_preview_close"):new Event("activity_link_preview_open"),document.dispatchEvent(e)},closeURLInput:function(){var e=new Event("activity_link_preview_close");document.dispatchEvent(e)},toggleGifSelector:function(e){e.preventDefault();var t=w(e.currentTarget).closest(".post-elements-buttons-item");t.hasClass("no-click")||t.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),this.$gifPickerEl.is(":empty")&&(this.gifMediaSearchDropdownView=new bp.Views.GifMediaSearchDropdown({model:this.model}),this.$gifPickerEl.html(this.gifMediaSearchDropdownView.render().el)),t=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container"),this.$self.hasClass("open")&&t.length&&""==w.trim(t.html())?this.$self.removeClass("open"):this.$self.addClass("open"),"bp_activity_edit"!==e.type&&this.$gifPickerEl.toggleClass("open"))},closeGifSelector:function(){Backbone.trigger("activity_gif_close")},toggleMediaSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeDocumentSelector(),this.closeVideoSelector(),Backbone.trigger("activity_media_toggle"))},toggleDocumentSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeGifSelector(),this.closeMediaSelector(),this.closeVideoSelector(),Backbone.trigger("activity_document_toggle"))},toggleVideoSelector:function(e){e.preventDefault();e=w(e.currentTarget).closest(".post-elements-buttons-item");!w(".activity-form").hasClass("focus-in")||e.hasClass("no-click")||e.hasClass("disable")||(this.closeMediaSelector(),this.closeDocumentSelector(),this.closeGifSelector(),Backbone.trigger("activity_video_toggle"))},closeMediaSelector:function(){Backbone.trigger("activity_media_close")},closeDocumentSelector:function(){Backbone.trigger("activity_document_close")},closeVideoSelector:function(){Backbone.trigger("activity_video_close")},closePickersOnEsc:function(e){"Escape"!==e.key&&27!==e.keyCode||_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||(this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},closePickersOnClick:function(e){var e=w(e.target);_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.gif_api_key)||e.closest(".post-gif").length||((e=e.parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container")).length&&""!==w.trim(e.html())?this.$self.addClass("open"):this.$self.removeClass("open"),this.$gifPickerEl.removeClass("open"))},activeButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"):(this.$el.find(".post-elements-buttons-item:not( .post-gif ):not( .post-media ):not( .post-video )").removeClass("active"),e.currentTarget.classList.add("active"));e=w(e.currentTarget).parents("#whats-new-form").find("#whats-new-attachments .activity-attached-gif-container");e.length&&""==w.trim(e.html())&&this.$self.removeClass("open")},activeMediaButton:function(e){w(e.currentTarget).hasClass("active")?this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"):(this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media, .post-elements-buttons-item.post-video").removeClass("active"),e.currentTarget.classList.add("active"))},activeVideoButton:function(e){this.$el.find(".post-elements-buttons-item.post-gif, .post-elements-buttons-item.post-media").removeClass("active"),w(e.currentTarget).hasClass("active")?e.currentTarget.classList.remove("active"):e.currentTarget.classList.add("active")},disabledButton:function(){Backbone.trigger("onError",BP_Nouveau.activity.params.errors.media_fail,"info noMediaError")},scrollToMedia:function(){var e=this.$el.closest("#whats-new-form").find(".whats-new-scroll-view");e.stop().animate({scrollTop:e[0].scrollHeight},300)}}),bp.Views.ActivityAttachments=bp.View.extend({tagName:"div",id:"whats-new-attachments",activityLinkPreview:null,activityAttachedGifPreview:null,activityMedia:null,activityDocument:null,activityVideo:null,className:"empty",initialize:function(){_.isUndefined(BP_Nouveau.activity.params.link_preview)||(this.activityLinkPreview=new bp.Views.ActivityLinkPreview({model:this.model}),this.views.add(this.activityLinkPreview)),_.isUndefined(window.Dropzone)||(this.activityMedia=new bp.Views.ActivityMedia({model:this.model}),this.views.add(this.activityMedia),this.activityDocument=new bp.Views.ActivityDocument({model:this.model}),this.views.add(this.activityDocument),this.activityVideo=new bp.Views.ActivityVideo({model:this.model}),this.views.add(this.activityVideo)),this.activityAttachedGifPreview=new bp.Views.ActivityAttachedGifPreview({model:this.model}),this.views.add(this.activityAttachedGifPreview)},onClose:function(){bp.draft_activity.data&&(bp.draft_activity.allow_delete_media=!1,bp.draft_activity.display_post=""),_.isNull(this.activityLinkPreview)||this.activityLinkPreview.destroy(),_.isNull(this.activityAttachedGifPreview)||this.activityAttachedGifPreview.destroy(),_.isNull(this.activityMedia)||this.activityMedia.destroy(),_.isNull(this.activityDocument)||this.activityDocument.destroyDocument(),_.isNull(this.activityVideo)||this.activityVideo.destroyVideo()}}),bp.Views.FormButtons=bp.View.extend({tagName:"div",id:"whats-new-actions",initialize:function(){this.views.add(new bp.View({tagName:"ul",id:"whats-new-buttons"})),_.each(this.collection.models,function(e){this.addItemView(e)},this),this.collection.on("change:active",this.isActive,this)},addItemView:function(e){this.views.add("#whats-new-buttons",new bp.Views.FormButton({model:e}))},isActive:function(t){_.each(this.views._views[""],function(e,t){0!==t&&e.remove()}),!0===t.get("active")?(_.each(this.views._views["#whats-new-buttons"],function(e){e.model.get("id")!==t.get("id")&&(e.model.set("active",!1,{silent:!0}),e.$el.removeClass("active"),this.collection.trigger("reset:"+e.model.get("id"),this.model))},this),this.collection.trigger("display:"+t.get("id"),this)):this.collection.trigger("reset:"+t.get("id"),this.model)}}),bp.Views.FormButton=bp.View.extend({tagName:"li",className:"whats-new-button",template:bp.template("activity-post-form-buttons"),events:{click:"setActive"},setActive:function(e){var t=this.model.get("active")||!1;e.preventDefault(),!1===t?(this.$el.addClass("active"),this.model.set("active",!0)):(this.$el.removeClass("active"),this.model.set("active",!1))}}),bp.Views.FormSubmit=bp.View.extend({tagName:"div",id:"whats-new-submit",className:"in-profile",initialize:function(){this.reset=new bp.Views.ActivityInput({type:"reset",id:"aw-whats-new-reset",className:"text-button small",value:BP_Nouveau.activity.strings.cancelButton});var e=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(e=BP_Nouveau.activity.strings.updatePostButton),"scheduled"!==this.model.get("activity_action_type")&&"scheduled"!==this.model.get("activity_status")||(e=BP_Nouveau.activity.strings.updatePostButton),this.submit=new bp.Views.ActivityInput({model:this.model,type:"submit",id:"aw-whats-new-submit",className:"button",name:"aw-whats-new-submit",value:e}),this.views.set([this.submit,this.reset]),this.model.on("change:object",this.updateDisplay,this),this.model.on("change:posting",this.updateStatus,this),this.model.on("change:activity_action_type",this.updateSubmitLabel,this)},updateDisplay:function(e){_.isUndefined(e)||("user"!==e.get("object")?this.$el.removeClass("in-profile"):this.$el.hasClass("in-profile")||this.$el.addClass("in-profile"))},updateStatus:function(e){_.isUndefined(e)||(e.get("posting")?(this.submit.el.disabled=!0,this.reset.el.disabled=!0,this.submit.el.classList.add("loading")):(this.submit.el.disabled=!1,this.reset.el.disabled=!1,this.submit.el.classList.remove("loading")))},updateSubmitLabel:function(e){var t=BP_Nouveau.activity.strings.postUpdateButton;w("#whats-new-form").hasClass("bp-activity-edit")&&(t=BP_Nouveau.activity.strings.updatePostButton),"scheduled"===e.get("activity_action_type")||"scheduled"===this.model.get("activity_status")?this.submit.el.value=void 0!==BP_Nouveau.activity_schedule?BP_Nouveau.activity_schedule.strings.schedulePostButton:"":this.submit.el.value=t}}),bp.Views.EditActivityPostIn=bp.View.extend({template:bp.template("activity-edit-postin"),initialize:function(){this.model.on("change",this.render,this)},render:function(){return this.$el.html(this.template(this.model.attributes)),this}}),bp.Views.FormSubmitWrapper=bp.View.extend({tagName:"div",id:"activity-form-submit-wrapper",initialize:function(){w("#whats-new-form").addClass("focus-in").parent().addClass("modal-popup").closest("body").addClass("activity-modal-open"),w("#bp-nouveau-activity-form-placeholder").show(),this.views.add(new bp.Views.ActivityInput({model:this.model,type:"button",id:"discard-draft-activity",className:"button outline",name:"discard-draft-activity",value:BP_Nouveau.activity.strings.discardButton})),void 0!==bp.Views.activitySchedulePost&&this.views.add(new bp.Views.activitySchedulePost({model:this.model})),this.views.add(new bp.Views.FormSubmit({model:this.model}))}}),bp.Views.PostForm=bp.View.extend({tagName:"form",className:"activity-form",id:"whats-new-form",attributes:{name:"whats-new-form",method:"post"},events:{"focus #whats-new":"displayFull","input #whats-new":"postValidate",reset:"resetForm",submit:"postUpdate",keydown:"postUpdate","click #whats-new-toolbar":"triggerDisplayFull","change .medium-editor-toolbar-input":"mediumLink","click #discard-draft-activity":"discardDraftActivity"},initialize:function(){var e,t=_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"]);_.isUndefined(BP_Nouveau.activity_schedule)||(e=_.pick(BP_Nouveau.activity_schedule.params,["can_schedule_in_feed"]),t=_.extend(t,e)),this.model=new bp.Models.Activity(t),this.listenTo(Backbone,"mediaprivacy",this.updateMultiMediaOptions),this.listenTo(Backbone,"mediaprivacytoolbar",this.updateMultiMediaToolbar),this.listenTo(Backbone,"onError",this.onError),this.listenTo(Backbone,"cleanFeedBack",this.cleanFeedback),this.listenTo(Backbone,"triggerToastMessage",this.triggerToastMessage),"user"===BP_Nouveau.activity.params.object&&(BP_Nouveau.activity.params.access_control_settings.can_create_activity?this.$el.removeClass("bp-hide"):this.$el.addClass("bp-hide")),this.resetModel=this.model.clone(),this.views.set([new bp.Views.ActivityHeader({model:this.model}),new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.PrivacyStage({model:this.model}),new bp.Views.FormContent({activity:this.model,model:this.model}),new bp.Views.EditorToolbar({model:this.model}),new bp.Views.ActivityToolbar({model:this.model})]),this.model.on("change:errors",this.displayFeedback,this);var i=this;w(document).ready(function(e){w("#whats-new-form").closest("body").addClass("initial-post-form-open"),w("body").hasClass("initial-post-form-open")&&(i.displayFull(e),i.$el.closest(".activity-update-form").find("#aw-whats-new-reset").trigger("click")),_.isUndefined(BP_Nouveau.media)||_.isUndefined(BP_Nouveau.media.emoji)||!(!_.isUndefined(BP_Nouveau.media.emoji.profile)&&BP_Nouveau.media.emoji.profile||!_.isUndefined(BP_Nouveau.media.emoji.groups)&&BP_Nouveau.media.emoji.groups)||w("#whats-new").emojioneArea({standalone:!0,hideSource:!1,container:"#editor-toolbar > .post-emoji",autocomplete:!1,pickerPosition:"bottom",hidePickerOnBlur:!0,useInternalCDN:!1,events:{emojibtn_click:function(){var e;w("#whats-new")[0].emojioneArea.hidePicker(),window.getSelection&&document.createRange?(e=window.getSelection&&window.getSelection())&&0/gi,"\n").replace(/<\/div>/gi,""));""===(t=t.replace(/ /g," ")).replace(/

/gi,"").replace(/<\/p>/gi,"").replace(/
/gi,"")&&(e[0].innerHTML=""),""!==w(w.parseHTML(t)).text().trim()||t.includes('class="emoji"')||!_.isUndefined(this.model.get("link_success"))&&!0===this.model.get("link_success")||!_.isUndefined(this.model.get("video"))&&0!==this.model.get("video").length||!_.isUndefined(this.model.get("document"))&&0!==this.model.get("document").length||!_.isUndefined(this.model.get("media"))&&0!==this.model.get("media").length||!_.isUndefined(this.model.get("gif_data"))&&!_.isEmpty(this.model.get("gif_data"))?this.$el.removeClass("focus-in--empty"):this.$el.addClass("focus-in--empty")},mediumLink:function(){""!==w(".medium-editor-toolbar-input").val()&&w("#whats-new-form").removeClass("focus-in--empty")},displayFull:function(e){var t;6!==this.views._views[""].length&&w(this.views._views[""][6].$el).hasClass("updated")&&(this.cleanFeedback(),w("#whats-new-form").removeClass("bottom-notice")),6===this.views._views[""].length&&("focusin"===e.type&&w("#whats-new-form").closest("body").removeClass("initial-post-form-open").addClass(e.type+"-post-form-open"),this.model.on("change:video change:document change:media change:gif_data change:privacy, change:link_success",this.postValidate,this),t=this,_.each(this.views._views[""],function(e){"message-feedabck"!==e.$el.prop("id")||e.$el.hasClass("noMediaError")||(t.cleanFeedback(),t.$el.removeClass("has-feedback"))}),_.each(this.views._views[""],function(e,t){4

'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer"),_.isUndefined(BP_Nouveau.activity_schedule)||_.isUndefined(typeof BP_Nouveau.activity_schedule.params.can_schedule_in_feed)||!0!==BP_Nouveau.activity_schedule.params.can_schedule_in_feed||w("#whats-new-form").find(".bb-schedule-post_dropdown_section").removeClass("bp-hide")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),null!==window.activityMediaAction&&(w(".activity-update-form.modal-popup").find("#"+window.activityMediaAction).trigger("click"),window.activityMediaAction=null),0===w(".activity-update-form .activity-update-form-overlay").length&&w(".activity-update-form.modal-popup").prepend('
'),this.activityHideModalEvent(),w("body").hasClass(e.type+"-post-form-open")&&!w("#whats-new-form").hasClass("bp-activity-edit")&&(bp.draft_local_interval||(bp.draft_local_interval=setInterval(function(){bp.Nouveau.Activity.postForm.storeDraftActivity()},3e3)),bp.draft_ajax_interval||(bp.draft_ajax_interval=setInterval(function(){bp.Nouveau.Activity.postForm.postDraftActivity(!1,!1)},2e4)),bp.Nouveau.Activity.postForm.displayDraftActivity()),w("a.bp-suggestions-mention:empty").remove())},activityHideModalEvent:function(){w(document).on("keyup",function(e){27===e.keyCode&&!1===e.ctrlKey&&setTimeout(function(){w(".activity-update-form.modal-popup #whats-new").blur(),w(".activity-update-form.modal-popup #aw-whats-new-reset").trigger("click");var e=w("#bp-nouveau-single-activity-edit-form-wrap");e.length&&e.hide()},0)})},triggerDisplayFull:function(e){var t,i;e.preventDefault(),(w(e.target).hasClass("toolbar-button")||w(e.target).parent().hasClass("toolbar-button"))&&(window.activityMediaAction=w(e.target).parent().attr("id"),void 0===window.activityMediaAction&&(window.activityMediaAction=w(e.target).attr("id"))),this.$el.hasClass("focus-in")||(t=this.$el.find("#whats-new")[0],i=window.getSelection(),(e=document.createRange()).setStart(t,0),e.setEnd(t,0),i.removeAllRanges(),i.addRange(e))},resetForm:function(){_.each(this.views._views[""],function(e,t){4/gi,"\n").replace(/<\/div>/gi,""))).replace(/ /g," ");f.model.set("content",s,{silent:!0}),f.model.set(t,{silent:!0});var d=f.model.get("media");if("group"==f.model.get("object")&&!_.isUndefined(d)&&d.length){for(var n=0;n"+p+' '+u+"
","success",m,!0))),o?b&&"scheduled"!==g.activity_action_type&&w("#activity-"+e.id).length?(w("#activity-"+e.id).replaceWith(e.activity),c=e.activity.indexOf('data-bp-activity="')+'data-bp-activity="'.length,p=e.activity.indexOf('"',c),u=e.activity.substring(c,p),m=f.decodeHtml(u),l=JSON.parse(m),o=w("
").html(l.content).html(),l.content=o,p=(c=w("#activity-modal .activity-list .activity-item")).find(".activity-content").find(".activity-inner"),u=c.find(".bb-media-privacy-wrap").find(".privacy-wrap").find(".privacy"),m=c.find(".bb-media-privacy-wrap").find(".activity-privacy li"),0").addClass("activity-list item-list bp-list")),0
'),w(".activity-update-form #whats-new-form").find("#whats-new-toolbar").appendTo(".whats-new-form-footer"),w(".activity-update-form #whats-new-form").find("#activity-form-submit-wrapper").appendTo(".whats-new-form-footer")),w(".activity-update-form .whats-new-scroll-view").length?w(".activity-update-form #whats-new-attachments").appendTo(".activity-update-form .whats-new-scroll-view"):(w(".activity-update-form .whats-new-form-header, .activity-update-form #whats-new-attachments").wrapAll('
'),w(".whats-new-scroll-view").on("scroll",function(){/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||w(".atwho-container #atwho-ground-whats-new .atwho-view").hide()}),w(window).on("resize",function(){w(".atwho-container #atwho-ground-whats-new .atwho-view:visible").hide()})),this.updateMultiMediaOptions(),bp.Nouveau.Activity.postForm.resetDraftActivity(!0)}}),bp.Views.PostFormPlaceholder=bp.View.extend({tagName:"form",className:"activity-form-placeholder",id:"whats-new-form-placeholder",initialize:function(){this.model=new bp.Models.Activity(_.pick(BP_Nouveau.activity.params,["user_id","item_id","object"])),this.resetModel=this.model.clone(),this.views.set([new bp.Views.UserStatusHuddle({model:this.model}),new bp.Views.FormPlaceholderContent({activity:this.model,model:this.model}),new bp.Views.ActivityToolbar({model:this.model})])}}),bp.Views.FormPlaceholderContent=bp.View.extend({tagName:"div",id:"whats-new-content-placeholder",initialize:function(){this.$el.html(w("
").prop("id","whats-new-textarea-placeholder")),this.views.set("#whats-new-textarea-placeholder",new bp.Views.WhatsNewPlaceholder)}}),bp.Views.WhatsNewPlaceholder=bp.View.extend({tagName:"div",className:"bp-suggestions-placehoder",id:"whats-new-placeholder",attributes:{name:"whats-new-placeholder",cols:"50",rows:"4",placeholder:BP_Nouveau.activity.strings.whatsnewPlaceholder,"aria-label":BP_Nouveau.activity.strings.whatsnewLabel,contenteditable:!0}}),bp.Views.PostGifProfile=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.profile)&&!1===BP_Nouveau.media.gif.profile||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Views.PostGifGroup=bp.View.extend({initialize:function(){!_.isUndefined(BP_Nouveau.media.gif.groups)&&!1===BP_Nouveau.media.gif.groups||""===BP_Nouveau.media.gif_api_key?w("#whats-new-toolbar .post-gif").removeClass("active").addClass("post-gif-hide"):w("#whats-new-toolbar .post-gif").removeClass("post-gif-hide")}}),bp.Nouveau.Activity.postForm.start())}((bp,jQuery)); \ No newline at end of file