diff --git a/message/output/popup/amd/build/message_popover_controller.min.js b/message/output/popup/amd/build/message_popover_controller.min.js index 313d91131d8..dd61230ca31 100644 --- a/message/output/popup/amd/build/message_popover_controller.min.js +++ b/message/output/popup/amd/build/message_popover_controller.min.js @@ -1 +1 @@ -define(["jquery","core/ajax","core/templates","core/str","core/notification","core/custom_interaction_events","core/popover_region_controller","core_message/message_repository","core/url"],function(a,b,c,d,e,f,g,h,i){var j={MARK_ALL_READ_BUTTON:'[data-action="mark-all-read"]',CONTENT:'[data-region="messages"]',CONTENT_ITEM_CONTAINER:'[data-region="message-content-item-container"]',EMPTY_MESSAGE:'[data-region="empty-message"]',COUNT_CONTAINER:'[data-region="count-container"]'},k=function(a){g.call(this,a),this.markAllReadButton=this.root.find(j.MARK_ALL_READ_BUTTON),this.content=this.root.find(j.CONTENT),this.userId=this.root.attr("data-userid"),this.limit=20,this.offset=0,this.loadedAll=!1,this.initialLoad=!1,this.loadUnreadMessageCount()};return k.prototype=Object.create(g.prototype),k.prototype.constructor=k,k.prototype.getContent=function(){return this.content},k.prototype.incrementOffset=function(){this.offset+=this.limit},k.prototype.updateButtonAriaLabel=function(){this.isMenuOpen()?d.get_string("hidemessagewindow","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):this.unreadCount?d.get_string("showmessagewindowwithcount","message",this.unreadCount).done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):d.get_string("showmessagewindownonew","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this))},k.prototype.renderUnreadCount=function(){var a=this.root.find(j.COUNT_CONTAINER);this.unreadCount?(a.text(this.unreadCount),a.removeClass("hidden")):a.addClass("hidden")},k.prototype.hideUnreadCount=function(){this.root.find(j.COUNT_CONTAINER).addClass("hidden")},k.prototype.loadUnreadMessageCount=function(){h.countUnreadConversations({useridto:this.userId}).then(function(a){this.unreadCount=a,this.renderUnreadCount(),this.updateButtonAriaLabel()}.bind(this))["catch"](e.exception)},k.prototype.renderMessages=function(b,d){var e=[];return a.each(b,function(a,b){b.contexturl=i.relativeUrl("/message/index.php",{user:this.userId,id:b.userid}),b.profileurl=i.relativeUrl("/user/profile.php",{id:b.userid});var f=c.render("message_popup/message_content_item",b).then(function(a,b){d.append(a),c.runTemplateJS(b)});e.push(f)}.bind(this)),a.when.apply(a,e)},k.prototype.loadMoreMessages=function(){if(this.isLoading||this.loadedAll)return a.Deferred().resolve();this.startLoading();var b={userid:this.userId,limit:this.limit,offset:this.offset},c=this.getContent();return h.query(b).then(function(a){var b=a.contacts;return this.loadedAll=!b.length||b.lengthc.innerHeight()){var e=a.outerHeight();e=4*e;var f=b.top-e;c.scrollTop(f)}},i.prototype.showNotification=function(b){if("object"!=typeof b&&(b=this.getNotificationElement(b)),b&&b.length){this.getRoot().find(g.NOTIFICATION).removeClass("selected"),b.addClass("selected").find(g.CAN_RECEIVE_FOCUS).focus();var c=b.attr("data-id"),d=this.getCacheNotification(c);this.scrollNotificationIntoView(b),this.getContainer().trigger(f.showNotification,[a.extend({},d)])}},i.prototype.markNotificationAsRead=function(a){return e.markAsRead(a.attr("data-id")).done(function(){a.removeClass("unread")})},i.prototype.renderNotifications=function(c){var d=[],e=this.getContent();return a.each(c,function(a,c){var f=c.contexturl;delete c.contexturl;var g=b.render(h.NOTIFICATION,c).then(function(a,d){e.append(a),b.runTemplateJS(d),c.contexturl=f,this.setCacheNotification(c)}.bind(this));d.push(g)}.bind(this)),a.when.apply(a,d)},i.prototype.loadMoreNotifications=function(){if(this.isLoading||this.hasLoadedAllContent())return a.Deferred().resolve();this.startLoading();var b={limit:this.getLimit(),offset:this.getOffset(),useridto:this.getUserId()};this.initialLoad||(b.limit=this.getOffset()+this.getLimit(),b.offset=0);var c=e.query(b).then(function(a){var b=a.notifications;return this.unreadCount=a.unreadcount,this.setLoadedAllContent(!b.length||b.lengthc.innerHeight()){var e=a.outerHeight();e=4*e;var f=b.top-e;c.scrollTop(f)}},i.prototype.showNotification=function(b){if("object"!=typeof b&&(b=this.getNotificationElement(b)),b&&b.length){this.getRoot().find(g.NOTIFICATION).removeClass("selected"),b.addClass("selected").find(g.CAN_RECEIVE_FOCUS).focus();var c=b.attr("data-id"),d=this.getCacheNotification(c);this.scrollNotificationIntoView(b),this.getContainer().trigger(f.showNotification,[a.extend({},d)])}},i.prototype.markNotificationAsRead=function(a){return e.markAsRead(a.attr("data-id")).done(function(){a.removeClass("unread")})},i.prototype.renderNotifications=function(c){var d=[],e=this.getContent();return a.each(c,function(a,c){var e=c.contexturl;delete c.contexturl;var f=b.render(h.NOTIFICATION,c).then(function(a,b){return c.contexturl=e,this.setCacheNotification(c),[a,b]}.bind(this));d.push(f)}.bind(this)),a.when.apply(a,d).then(function(){a.each(arguments,function(a,c){e.append(c[0]),b.runTemplateJS(c[1])})})},i.prototype.loadMoreNotifications=function(){if(this.isLoading||this.hasLoadedAllContent())return a.Deferred().resolve();this.startLoading();var b={limit:this.getLimit(),offset:this.getOffset(),useridto:this.getUserId()};this.initialLoad||(b.limit=this.getOffset()+this.getLimit(),b.offset=0);var c=e.query(b).then(function(a){var b=a.notifications;return this.unreadCount=a.unreadcount,this.setLoadedAllContent(!b.length||b.length