diff --git a/resources/js/humhub.mail.messenger.bundle.js b/resources/js/humhub.mail.messenger.bundle.js index a91b5c4..6c4a049 100644 --- a/resources/js/humhub.mail.messenger.bundle.js +++ b/resources/js/humhub.mail.messenger.bundle.js @@ -230,7 +230,7 @@ humhub.module('mail.ConversationView', function (module, require, $) { var observer = new MutationObserver(function () { that.updateSize(true); }); - filePreview.each(function () { + filePreview.each(function (index, element) { observer.observe(element, { childList: true, subtree: true }); }); diff --git a/resources/js/humhub.mail.messenger.bundle.min.js b/resources/js/humhub.mail.messenger.bundle.min.js index 94e4d1f..a4045a8 100644 --- a/resources/js/humhub.mail.messenger.bundle.min.js +++ b/resources/js/humhub.mail.messenger.bundle.min.js @@ -1 +1 @@ -humhub.module("mail.ConversationView",function(r,t,n){var s=t("ui.widget").Widget,a=t("ui.loader"),l=t("client"),i=t("ui.additions"),e=t("util.object"),o=t("mail.notification"),c=t("ui.view"),u=s.extend();u.prototype.init=function(){i.observe(this.$);var e=this;window.onresize=function(t){e.updateSize(!0)},this.getActiveMessageId()||this.setActiveMessageId(s.instance("#inbox").getFirstMessageId()),this.reload(),this.$.on("mouseenter",".mail-conversation-entry",function(){n(this).find(".conversation-menu").show()}).on("mouseleave",".mail-conversation-entry",function(){n(this).find(".conversation-menu").hide()})},u.prototype.loader=function(t){!1!==t?a.set(this.$):a.reset(this.$)},u.prototype.markSeen=function(t){l.post(this.options.markSeenUrl,{data:{id:t}}).then(function(t){e.isDefined(t.messageCount)&&o.setMailMessageCount(t.messageCount)}).catch(function(t){r.log.error(t)})},u.prototype.loadUpdate=function(){var t=this.$.find(".mail-conversation-entry:not(.own):last").data("entry-id"),t={id:this.getActiveMessageId(),from:t},e=this;l.get(this.options.loadUpdateUrl,{data:t}).then(function(t){t.html&&n(t.html).each(function(){e.appendEntry(n(this))})})},u.prototype.reply=function(e){var i=this;l.submit(e).then(function(t){t.success?i.appendEntry(t.content).then(function(){i.$.find(".time").timeago();var t=i.getReplyRichtext(),t=(t&&t.$.trigger("clear"),i.getReplyFilePreview()),t=(t.length&&(t.hide(),t.children("ul.files").html("")),i.getReplyFileListInputs());t.length&&t.remove(),i.scrollToBottom(),c.isSmall()||i.focus(),s.instance("#inbox").updateEntries([i.getActiveMessageId()]),i.setLivePollInterval()}):r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)}).finally(function(t){a.reset(n(".reply-button")),e.finish()})},u.prototype.setLivePollInterval=function(){t("live").setDelay(5)},u.prototype.getReplyRichtext=function(){return s.instance(this.$.find(".ProsemirrorEditor"))},u.prototype.getReplyFilePreview=function(){return this.$.find(".post-file-list")},u.prototype.getReplyFileListInputs=function(){return this.$.find('input[name="fileList[]"]')},u.prototype.focus=function(t){var e=this.getReplyRichtext();e&&e.focus()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.reload=function(){this.getActiveMessageId()&&this.loadMessage(this.getActiveMessageId())},u.prototype.addUser=function(t){var e=this;l.submit(t).then(function(t){t.result?e.$.find("#mail-conversation-header").html(t.result):t.error&&r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)})},u.prototype.appendEntry=function(t){var i,o=this,t=n(t);return o.$.find('[data-entry-id="'+t.data("entryId")+'"]').length?Promise.resolve():((i=t.not("script, link").filter(function(){return 1===this.nodeType})).css("opacity",0),this.getListNode().append(t),new Promise(function(t,e){i.css("opacity",1).fadeIn("fast",function(){o.onUpdate(),setTimeout(function(){o.scrollToBottom()},100),t()})}))},u.prototype.loadMessage=function(i){var o=e.isNumber(i)?i:i.$trigger.data("message-id"),n=this;this.loader(),l.get(this.options.loadMessageUrl,{data:{id:o}}).then(function(t){n.setActiveMessageId(o),n.options.isLast=!1;var e=s.instance("#inbox");return e.updateActiveItem(),e.hide(),i.$trigger&&history&&history.replaceState&&(e=i.$trigger.data("action-url"))&&history.replaceState(null,null,e),n.$.css("visibility","hidden"),n.updateContent(t.html)}).then(function(){return n.initScroll()}).catch(function(t){r.log.error(t,!0)}).finally(function(){n.loader(!1),n.$.css("visibility","visible"),n.initReplyRichText()})},u.prototype.initReplyRichText=function(){var t,e=this,i=(window.ResizeObserver&&(i=new ResizeObserver(function(t){e.updateSize(e.isScrolledToBottom(100))}),t=e.getReplyRichtext())&&i.observe(t.$[0]),e.getReplyFilePreview()),o=new MutationObserver(function(){e.updateSize(!0)});i.each(function(){o.observe(element,{childList:!0,subtree:!0})}),e.focus()},u.prototype.isScrolledToBottom=function(t){if(!this.getListNode().length)return!1;t=t||0;var e=this.getListNode()[0];return e.scrollHeight-e.offsetHeight-e.scrollTop<=t},u.prototype.initScroll=function(){var e,t,i,o;if(window.IntersectionObserver)return e=this.getListNode(),t=n('
'),e.prepend(t),i=this,o=new IntersectionObserver(function(t){i.preventScrollLoading()||t.length&&t[0].isIntersecting&&(a.prepend(e),i.loadMore().finally(function(){a.reset(e)}))},{root:e[0],rootMargin:"50px"}),this.assureScroll().then(function(){o.observe(t[0]),c.isLarge()&&(i.getListNode().niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:0,left:0,bottom:0}}),i.scrollDownButton=void 0,i.getListNode().on("scroll",()=>i.getScrollDownButton().toggle(!i.isScrolledToBottom())))})},u.prototype.getScrollDownButton=function(){return"object"!=typeof this.scrollDownButton&&(this.scrollDownButton=n("
").addClass("conversation-scroll-down-button").html('').on("click",()=>this.scrollToBottom()),this.getListNode().append(this.scrollDownButton)),this.scrollDownButton},u.prototype.loadMore=function(){var i=this,t={id:this.getActiveMessageId(),from:this.$.find(".mail-conversation-entry:first").data("entryId")};return l.get(this.options.loadMoreUrl,{data:t}).then(function(t){var e;t.result&&(e=n(t.result).hide(),i.getListNode().find(".conversation-stream-end").after(e),e.fadeIn()),i.options.isLast=!t.result||t.isLast}).catch(function(t){r.log.error(t,!0)})},u.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.assureScroll=function(){var t=this,e=this.getListNode();return e[0].offsetHeight>=e[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):t.scrollToBottom()},u.prototype.updateContent=function(e){var i=this;return new Promise(function(t){i.$.html(e),t()})},u.prototype.getActiveMessageId=function(){return this.options.messageId},u.prototype.setActiveMessageId=function(t){this.options.messageId=t},u.prototype.scrollToBottom=function(){var i=this;return new Promise(function(e){setTimeout(function(){i.$.imagesLoaded(function(){var t=i.getListNode();t.length&&i.updateSize(!1).then(function(){t[0].scrollTop=t[0].scrollHeight,e()})})})})},u.prototype.updateSize=function(n){var r=this;return new Promise(function(o){setTimeout(function(){var t,e,i=r.getListNode();i.length&&(t=(t=r.getReplyRichtext())?t.$.closest(".mail-message-form").innerHeight():0,i.css("margin-bottom",t+5+"px"),e=r.getListNode().offset().top,e=window.innerHeight-e-t-(c.isSmall()?20:30)+"px",i.css("height",e),i.css("max-height",e),!1!==n&&r.scrollToBottom(),o())},100)})},u.prototype.getListNode=function(){return this.$.find(".conversation-entry-list")},u.prototype.onUpdate=function(){c.isLarge()&&this.getListNode().getNiceScroll().resize()},r.export=u}),humhub.module("mail.ConversationEntry",function(t,e,o){e=e("ui.widget").Widget.extend();e.prototype.replace=function(t){var e=this,i=o(t).hide();this.$.fadeOut(function(){o(this).replaceWith(i),e.$=i,e.$.fadeIn("slow")})},e.prototype.remove=function(){this.$.fadeToggle("slow",function(){o(this).remove()})},t.export=e}),humhub.module("mail.inbox",function(n,t,r){var e=t("ui.widget").Widget,i=t("ui.filter").Filter,o=t("ui.view"),s=t("ui.loader"),a=t("client"),t=i.extend(),i=(t.prototype.triggerChange=function(){this.super("triggerChange"),this.updateFilterCount()},t.prototype.updateFilterCount=function(){var t=this.getActiveFilterCount(),e=this.$.find("#conversation-filter-link"),i=e.find(".filterCount");t?(i=i.length?i:r('').insertBefore(e.find(".caret"))).html(" ("+t+") "):i.length&&i.remove()},e.extend()),l=(i.prototype.init=function(){this.filter=e.instance("#mail-filter-root"),this.initScroll(),this.initHeight();var t=this;this.filter.off("afterChange.inbox").on("afterChange.inbox",function(){t.reload().then(function(){t.updateActiveItem()})}),o.isLarge()&&this.$.niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:3,left:0,bottom:0}}),this.$.on("click",".entry",function(){t.$.find(".entry").removeClass("selected"),r(this).addClass("selected")})},i.prototype.initHeight=function(){var t=this.$.offset().top;this.$.css("max-height",window.innerHeight-t-15+"px")},i.prototype.updateEntries=function(t){var i=this;t.length&&a.get(this.options.updateEntriesUrl,{data:{ids:t}}).then(function(t){t.result&&(r.each(t.result,function(t,e){t=i.getEntry(t);t.length?t.replaceWith(e):r(e).prependTo(i.$)}),i.updateActiveItem())}).catch(function(t){n.log.error(t)})},i.prototype.getEntry=function(t){return this.$.find('[data-message-id="'+t+'"]')},i.prototype.initScroll=function(){var t,e,i;window.IntersectionObserver&&(t=r('
'),this.$.append(t),e=this,i=new IntersectionObserver(function(t){e.preventScrollLoading()||t.length&&t[0].isIntersecting&&(s.append(e.$),e.loadMore().finally(function(){s.reset(e.$)}))},{root:this.$[0],rootMargin:"50px"}),this.assureScroll().then(function(){i.observe(t[0])}))},i.prototype.assureScroll=function(){var t=this;return this.$[0].offsetHeight>=this.$[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):Promise.resolve()},i.prototype.loadMore=function(){var o=this;return new Promise(function(e,i){var t=o.filter.getFilterMap();t.from=o.getLastMessageId(),a.get(o.options.loadMoreUrl,{data:t}).then(function(t){t.result&&(r(t.result).insertBefore(".inbox-stream-end"),o.$.find(".inbox-stream-end").append()),o.options.isLast=!t.result||t.isLast,o.updateActiveItem(),e()}).catch(function(t){n.log.error(t,!0),i()}).finally(function(){o.scrollLock=!1})})},i.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},i.prototype.canLoadMore=function(){return!this.options.isLast},i.prototype.getReloadOptions=function(){return{data:this.filter.getFilterMap()}},i.prototype.updateActiveItem=function(){var t;this.$.find(".entry").removeClass("selected"),l=null,c()&&(t=this.$.find('[data-message-id="'+c().getActiveMessageId()+'"]')).length&&t.removeClass("unread").addClass("selected")},i.prototype.getFirstMessageId=function(){return this.$.find(".entry:first").data("message-id")},i.prototype.getLastMessageId=function(){return this.$.find(".entry:last").data("message-id")},i.prototype.hide=function(){return new Promise(function(t){o.isSmall()&&r(".mail-conversation-single-message").length&&r(".inbox-wrapper").slideUp(function(){c()&&c().updateSize(),t()}),t()})},i.prototype.show=function(){return new Promise(function(t){o.isSmall()&&r(".inbox-wrapper").slideDown(function(){c()&&c().updateSize(),t()}),t()})},null),c=function(){return l=l||e.instance("#mail-conversation-root")};n.export({ConversationList:i,Filter:t,setTagFilter:function(t){e.instance("#inbox").show().then(function(){r("#mail-filter-menu").collapse("show"),e.instance("#inbox-tag-picker").setSelection([{id:t.$trigger.data("tagId"),text:t.$trigger.data("tagName"),image:t.$trigger.data("tagImage")}])})},toggleInbox:function(){o.isSmall()&&r(".inbox-wrapper").slideToggle(function(){c()&&c().updateSize()})}})}),humhub.module("mail.conversation",function(o,t,r){function n(t){return s.instance('.mail-conversation-entry[data-entry-id="'+t+'"]')}var s=t("ui.widget").Widget,a=t("ui.modal"),i=t("client"),e=t("event"),l=t("mail.notification");o.export({init:function(){e.on("humhub:modules:mail:live:NewUserMessage",function(t,e){var i,o,n;r("#inbox").length&&(i=s.instance("#mail-conversation-root"),o=!1,n=[],e.forEach(function(t){n.push(t.data.message_id),!o&&i&&i.options.messageId==t.data.message_id&&(i.loadUpdate(),o=!0,i.markSeen(t.data.message_id))}),s.instance("#inbox").updateEntries(n))}).on("humhub:modules:mail:live:UserMessageDeleted",function(t,e,i){r("#inbox").length&&e.forEach(function(t){var e=n(t.data.entry_id);e&&e.remove(),l.setMailMessageCount(t.data.count)})})},linkAction:function(t){i.post(t).then(function(t){t.redirect&&i.pjax.redirect(t.redirect)}).catch(function(t){o.log.error(t,!0)})},submitEditEntry:function(i){a.submit(i).then(function(t){var e;t.success?(e=n(i.$trigger.data("entry-id")))&&setTimeout(function(){e.replace(t.content)},300):o.log.error(null,!0)}).catch(function(t){o.log.error(t,!0)})},deleteEntry:function(t){var e=n(t.$trigger.data("entry-id"));e?i.post(e.options.deleteUrl).then(function(t){a.global.close(),t.success&&setTimeout(function(){e.remove()},1e3)}).catch(function(t){o.log.error(t,!0)}):o.log.error(null,!0)}})}); \ No newline at end of file +humhub.module("mail.ConversationView",function(r,t,n){var s=t("ui.widget").Widget,a=t("ui.loader"),l=t("client"),i=t("ui.additions"),e=t("util.object"),o=t("mail.notification"),c=t("ui.view"),u=s.extend();u.prototype.init=function(){i.observe(this.$);var e=this;window.onresize=function(t){e.updateSize(!0)},this.getActiveMessageId()||this.setActiveMessageId(s.instance("#inbox").getFirstMessageId()),this.reload(),this.$.on("mouseenter",".mail-conversation-entry",function(){n(this).find(".conversation-menu").show()}).on("mouseleave",".mail-conversation-entry",function(){n(this).find(".conversation-menu").hide()})},u.prototype.loader=function(t){!1!==t?a.set(this.$):a.reset(this.$)},u.prototype.markSeen=function(t){l.post(this.options.markSeenUrl,{data:{id:t}}).then(function(t){e.isDefined(t.messageCount)&&o.setMailMessageCount(t.messageCount)}).catch(function(t){r.log.error(t)})},u.prototype.loadUpdate=function(){var t=this.$.find(".mail-conversation-entry:not(.own):last").data("entry-id"),t={id:this.getActiveMessageId(),from:t},e=this;l.get(this.options.loadUpdateUrl,{data:t}).then(function(t){t.html&&n(t.html).each(function(){e.appendEntry(n(this))})})},u.prototype.reply=function(e){var i=this;l.submit(e).then(function(t){t.success?i.appendEntry(t.content).then(function(){i.$.find(".time").timeago();var t=i.getReplyRichtext(),t=(t&&t.$.trigger("clear"),i.getReplyFilePreview()),t=(t.length&&(t.hide(),t.children("ul.files").html("")),i.getReplyFileListInputs());t.length&&t.remove(),i.scrollToBottom(),c.isSmall()||i.focus(),s.instance("#inbox").updateEntries([i.getActiveMessageId()]),i.setLivePollInterval()}):r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)}).finally(function(t){a.reset(n(".reply-button")),e.finish()})},u.prototype.setLivePollInterval=function(){t("live").setDelay(5)},u.prototype.getReplyRichtext=function(){return s.instance(this.$.find(".ProsemirrorEditor"))},u.prototype.getReplyFilePreview=function(){return this.$.find(".post-file-list")},u.prototype.getReplyFileListInputs=function(){return this.$.find('input[name="fileList[]"]')},u.prototype.focus=function(t){var e=this.getReplyRichtext();e&&e.focus()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.reload=function(){this.getActiveMessageId()&&this.loadMessage(this.getActiveMessageId())},u.prototype.addUser=function(t){var e=this;l.submit(t).then(function(t){t.result?e.$.find("#mail-conversation-header").html(t.result):t.error&&r.log.error(t,!0)}).catch(function(t){r.log.error(t,!0)})},u.prototype.appendEntry=function(t){var i,o=this,t=n(t);return o.$.find('[data-entry-id="'+t.data("entryId")+'"]').length?Promise.resolve():((i=t.not("script, link").filter(function(){return 1===this.nodeType})).css("opacity",0),this.getListNode().append(t),new Promise(function(t,e){i.css("opacity",1).fadeIn("fast",function(){o.onUpdate(),setTimeout(function(){o.scrollToBottom()},100),t()})}))},u.prototype.loadMessage=function(i){var o=e.isNumber(i)?i:i.$trigger.data("message-id"),n=this;this.loader(),l.get(this.options.loadMessageUrl,{data:{id:o}}).then(function(t){n.setActiveMessageId(o),n.options.isLast=!1;var e=s.instance("#inbox");return e.updateActiveItem(),e.hide(),i.$trigger&&history&&history.replaceState&&(e=i.$trigger.data("action-url"))&&history.replaceState(null,null,e),n.$.css("visibility","hidden"),n.updateContent(t.html)}).then(function(){return n.initScroll()}).catch(function(t){r.log.error(t,!0)}).finally(function(){n.loader(!1),n.$.css("visibility","visible"),n.initReplyRichText()})},u.prototype.initReplyRichText=function(){var t,e=this,i=(window.ResizeObserver&&(i=new ResizeObserver(function(t){e.updateSize(e.isScrolledToBottom(100))}),t=e.getReplyRichtext())&&i.observe(t.$[0]),e.getReplyFilePreview()),o=new MutationObserver(function(){e.updateSize(!0)});i.each(function(t,e){o.observe(e,{childList:!0,subtree:!0})}),e.focus()},u.prototype.isScrolledToBottom=function(t){if(!this.getListNode().length)return!1;t=t||0;var e=this.getListNode()[0];return e.scrollHeight-e.offsetHeight-e.scrollTop<=t},u.prototype.initScroll=function(){var e,t,i,o;if(window.IntersectionObserver)return e=this.getListNode(),t=n('
'),e.prepend(t),i=this,o=new IntersectionObserver(function(t){i.preventScrollLoading()||t.length&&t[0].isIntersecting&&(a.prepend(e),i.loadMore().finally(function(){a.reset(e)}))},{root:e[0],rootMargin:"50px"}),this.assureScroll().then(function(){o.observe(t[0]),c.isLarge()&&(i.getListNode().niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:0,left:0,bottom:0}}),i.scrollDownButton=void 0,i.getListNode().on("scroll",()=>i.getScrollDownButton().toggle(!i.isScrolledToBottom())))})},u.prototype.getScrollDownButton=function(){return"object"!=typeof this.scrollDownButton&&(this.scrollDownButton=n("
").addClass("conversation-scroll-down-button").html('').on("click",()=>this.scrollToBottom()),this.getListNode().append(this.scrollDownButton)),this.scrollDownButton},u.prototype.loadMore=function(){var i=this,t={id:this.getActiveMessageId(),from:this.$.find(".mail-conversation-entry:first").data("entryId")};return l.get(this.options.loadMoreUrl,{data:t}).then(function(t){var e;t.result&&(e=n(t.result).hide(),i.getListNode().find(".conversation-stream-end").after(e),e.fadeIn()),i.options.isLast=!t.result||t.isLast}).catch(function(t){r.log.error(t,!0)})},u.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},u.prototype.canLoadMore=function(){return!this.options.isLast},u.prototype.assureScroll=function(){var t=this,e=this.getListNode();return e[0].offsetHeight>=e[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):t.scrollToBottom()},u.prototype.updateContent=function(e){var i=this;return new Promise(function(t){i.$.html(e),t()})},u.prototype.getActiveMessageId=function(){return this.options.messageId},u.prototype.setActiveMessageId=function(t){this.options.messageId=t},u.prototype.scrollToBottom=function(){var i=this;return new Promise(function(e){setTimeout(function(){i.$.imagesLoaded(function(){var t=i.getListNode();t.length&&i.updateSize(!1).then(function(){t[0].scrollTop=t[0].scrollHeight,e()})})})})},u.prototype.updateSize=function(n){var r=this;return new Promise(function(o){setTimeout(function(){var t,e,i=r.getListNode();i.length&&(t=(t=r.getReplyRichtext())?t.$.closest(".mail-message-form").innerHeight():0,i.css("margin-bottom",t+5+"px"),e=r.getListNode().offset().top,e=window.innerHeight-e-t-(c.isSmall()?20:30)+"px",i.css("height",e),i.css("max-height",e),!1!==n&&r.scrollToBottom(),o())},100)})},u.prototype.getListNode=function(){return this.$.find(".conversation-entry-list")},u.prototype.onUpdate=function(){c.isLarge()&&this.getListNode().getNiceScroll().resize()},r.export=u}),humhub.module("mail.ConversationEntry",function(t,e,o){e=e("ui.widget").Widget.extend();e.prototype.replace=function(t){var e=this,i=o(t).hide();this.$.fadeOut(function(){o(this).replaceWith(i),e.$=i,e.$.fadeIn("slow")})},e.prototype.remove=function(){this.$.fadeToggle("slow",function(){o(this).remove()})},t.export=e}),humhub.module("mail.inbox",function(n,t,r){var e=t("ui.widget").Widget,i=t("ui.filter").Filter,o=t("ui.view"),s=t("ui.loader"),a=t("client"),t=i.extend(),i=(t.prototype.triggerChange=function(){this.super("triggerChange"),this.updateFilterCount()},t.prototype.updateFilterCount=function(){var t=this.getActiveFilterCount(),e=this.$.find("#conversation-filter-link"),i=e.find(".filterCount");t?(i=i.length?i:r('').insertBefore(e.find(".caret"))).html(" ("+t+") "):i.length&&i.remove()},e.extend()),l=(i.prototype.init=function(){this.filter=e.instance("#mail-filter-root"),this.initScroll(),this.initHeight();var t=this;this.filter.off("afterChange.inbox").on("afterChange.inbox",function(){t.reload().then(function(){t.updateActiveItem()})}),o.isLarge()&&this.$.niceScroll({cursorwidth:"7",cursorborder:"",cursorcolor:"#555",cursoropacitymax:"0.2",nativeparentscrolling:!1,railpadding:{top:0,right:3,left:0,bottom:0}}),this.$.on("click",".entry",function(){t.$.find(".entry").removeClass("selected"),r(this).addClass("selected")})},i.prototype.initHeight=function(){var t=this.$.offset().top;this.$.css("max-height",window.innerHeight-t-15+"px")},i.prototype.updateEntries=function(t){var i=this;t.length&&a.get(this.options.updateEntriesUrl,{data:{ids:t}}).then(function(t){t.result&&(r.each(t.result,function(t,e){t=i.getEntry(t);t.length?t.replaceWith(e):r(e).prependTo(i.$)}),i.updateActiveItem())}).catch(function(t){n.log.error(t)})},i.prototype.getEntry=function(t){return this.$.find('[data-message-id="'+t+'"]')},i.prototype.initScroll=function(){var t,e,i;window.IntersectionObserver&&(t=r('
'),this.$.append(t),e=this,i=new IntersectionObserver(function(t){e.preventScrollLoading()||t.length&&t[0].isIntersecting&&(s.append(e.$),e.loadMore().finally(function(){s.reset(e.$)}))},{root:this.$[0],rootMargin:"50px"}),this.assureScroll().then(function(){i.observe(t[0])}))},i.prototype.assureScroll=function(){var t=this;return this.$[0].offsetHeight>=this.$[0].scrollHeight&&this.canLoadMore()?this.loadMore().then(function(){return t.assureScroll()}).catch(function(){return Promise.resolve()}):Promise.resolve()},i.prototype.loadMore=function(){var o=this;return new Promise(function(e,i){var t=o.filter.getFilterMap();t.from=o.getLastMessageId(),a.get(o.options.loadMoreUrl,{data:t}).then(function(t){t.result&&(r(t.result).insertBefore(".inbox-stream-end"),o.$.find(".inbox-stream-end").append()),o.options.isLast=!t.result||t.isLast,o.updateActiveItem(),e()}).catch(function(t){n.log.error(t,!0),i()}).finally(function(){o.scrollLock=!1})})},i.prototype.preventScrollLoading=function(){return this.scrollLock||!this.canLoadMore()},i.prototype.canLoadMore=function(){return!this.options.isLast},i.prototype.getReloadOptions=function(){return{data:this.filter.getFilterMap()}},i.prototype.updateActiveItem=function(){var t;this.$.find(".entry").removeClass("selected"),l=null,c()&&(t=this.$.find('[data-message-id="'+c().getActiveMessageId()+'"]')).length&&t.removeClass("unread").addClass("selected")},i.prototype.getFirstMessageId=function(){return this.$.find(".entry:first").data("message-id")},i.prototype.getLastMessageId=function(){return this.$.find(".entry:last").data("message-id")},i.prototype.hide=function(){return new Promise(function(t){o.isSmall()&&r(".mail-conversation-single-message").length&&r(".inbox-wrapper").slideUp(function(){c()&&c().updateSize(),t()}),t()})},i.prototype.show=function(){return new Promise(function(t){o.isSmall()&&r(".inbox-wrapper").slideDown(function(){c()&&c().updateSize(),t()}),t()})},null),c=function(){return l=l||e.instance("#mail-conversation-root")};n.export({ConversationList:i,Filter:t,setTagFilter:function(t){e.instance("#inbox").show().then(function(){r("#mail-filter-menu").collapse("show"),e.instance("#inbox-tag-picker").setSelection([{id:t.$trigger.data("tagId"),text:t.$trigger.data("tagName"),image:t.$trigger.data("tagImage")}])})},toggleInbox:function(){o.isSmall()&&r(".inbox-wrapper").slideToggle(function(){c()&&c().updateSize()})}})}),humhub.module("mail.conversation",function(o,t,r){function n(t){return s.instance('.mail-conversation-entry[data-entry-id="'+t+'"]')}var s=t("ui.widget").Widget,a=t("ui.modal"),i=t("client"),e=t("event"),l=t("mail.notification");o.export({init:function(){e.on("humhub:modules:mail:live:NewUserMessage",function(t,e){var i,o,n;r("#inbox").length&&(i=s.instance("#mail-conversation-root"),o=!1,n=[],e.forEach(function(t){n.push(t.data.message_id),!o&&i&&i.options.messageId==t.data.message_id&&(i.loadUpdate(),o=!0,i.markSeen(t.data.message_id))}),s.instance("#inbox").updateEntries(n))}).on("humhub:modules:mail:live:UserMessageDeleted",function(t,e,i){r("#inbox").length&&e.forEach(function(t){var e=n(t.data.entry_id);e&&e.remove(),l.setMailMessageCount(t.data.count)})})},linkAction:function(t){i.post(t).then(function(t){t.redirect&&i.pjax.redirect(t.redirect)}).catch(function(t){o.log.error(t,!0)})},submitEditEntry:function(i){a.submit(i).then(function(t){var e;t.success?(e=n(i.$trigger.data("entry-id")))&&setTimeout(function(){e.replace(t.content)},300):o.log.error(null,!0)}).catch(function(t){o.log.error(t,!0)})},deleteEntry:function(t){var e=n(t.$trigger.data("entry-id"));e?i.post(e.options.deleteUrl).then(function(t){a.global.close(),t.success&&setTimeout(function(){e.remove()},1e3)}).catch(function(t){o.log.error(t,!0)}):o.log.error(null,!0)}})}); \ No newline at end of file