framework/extensions/likes/js/dist/forum.js

2 lines
4.2 KiB
JavaScript
Raw Normal View History

(()=>{var t={n:o=>{var n=o&&o.__esModule?()=>o.default:()=>o;return t.d(n,{a:n}),n},d:(o,n)=>{for(var e in n)t.o(n,e)&&!t.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:n[e]})},o:(t,o)=>Object.prototype.hasOwnProperty.call(t,o),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},o={};(()=>{"use strict";t.r(o);const n=flarum.core.compat["common/extend"],e=flarum.core.compat["forum/app"];var r=t.n(e);const s=flarum.core.compat["common/models/Post"];var a=t.n(s);const i=flarum.core.compat["common/Model"];var c=t.n(i);const u=flarum.core.compat["forum/components/NotificationGrid"];var l=t.n(u);const f=flarum.core.compat["common/components/Button"];var p=t.n(f);const d=flarum.core.compat["forum/components/CommentPost"];var k=t.n(d);const h=flarum.core.compat["common/components/Link"];var v=t.n(h);const y=flarum.core.compat["common/helpers/punctuateSeries"];var _=t.n(y);const b=flarum.core.compat["common/helpers/username"];var g=t.n(b);const P=flarum.core.compat["common/helpers/icon"];var L=t.n(P);function M(t,o){return M=Object.setPrototypeOf||function(t,o){return t.__proto__=o,t},M(t,o)}function x(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,M(t,o)}const j=flarum.core.compat["common/components/Modal"];var O=t.n(j);const N=flarum.core.compat["common/helpers/avatar"];var S=t.n(N),B=function(t){function o(){return t.apply(this,arguments)||this}x(o,t);var n=o.prototype;return n.className=function(){return"PostLikesModal Modal--small"},n.title=function(){return r().translator.trans("flarum-likes.forum.post_likes.title")},n.content=function(){return m("div",{className:"Modal-body"},m("ul",{className:"PostLikesModal-list"},this.attrs.post.likes().map((function(t){return m("li",null,m(v(),{href:r().route.user(t)},S()(t)," ",g()(t)))}))))},o}(O());const T=flarum.core.compat["forum/components/Notification"];var w=t.n(T);const C=flarum.core.compat["common/utils/string"];var I=function(t){function o(){return t.apply(this,arguments)||this}x(o,t);var n=o.prototype;return n.icon=function(){return"far fa-thumbs-up"},n.href=function(){return r().route.post(this.attrs.notification.subject())},n.content=function(){var t=this.attrs.notification.fromUser();return r().translator.trans("flarum-likes.forum.notifications.post_liked_text",{user:t,count:1})},n.excerpt=function(){return(0,C.truncate)(this.attrs.notification.subject().contentPlain(),200)},o}(w());r().initializers.add("flarum-likes",(function(){r().notificationComponents.postLiked=I,a().prototype.canLike=c().attribute("canLike"),a().prototype.likes=c().hasMany("likes"),(0,n.extend)(k().prototype,"actionItems",(function(t){var o=this.attrs.post;if(!o.isHidden()&&o.canLike()){var n=o.likes(),e=r().session.user&&n&&n.some((function(t){return t===r().session.user}));t.add("like",p().component({className:"Button Button--link",onclick:function(){e=!e,o.save({isLiked:e});var t=o.data.relationships.likes.data;t.some((function(o,n){if(o.id===r().session.user.id())return t.splice(n,1),!0})),e&&t.unshift({type:"users",id:r().session.user.id()})}},r().translator.trans(e?"flarum-likes.forum.post.unlike_link":"flarum-likes.forum.post.like_link")))}})),(0,n.extend)(k().prototype,"footerItems",(function(t){var o=this.attrs.post,n=o.likes();if(n&&n.length){var e=n.length>4,s=n.sort((function(t){return t===r().session.user?-1:1})).slice(0,e?3:4).map((function(t){return m(v(),{href:r().route.user(t)},t===r().session.user?r().translator.trans("flarum-likes.forum.post.you_text"):g()(t))}));if(e){var a=n.length-s.length;s.push(m("a",{href:"#",onclick:function(t){t.preventDefault(),r().modal.show(B,{post:o})}},r().translator.trans("flarum-likes.forum.post.others_link",{count:a})))}t.add("liked",m("div",{className:"Post-likedBy"},L()("far fa-thumbs-up"),r().translator.trans("flarum-likes.forum.post.liked_by"+(n[0]===r().session.user?"_self":"")+"_text",{count:s.length,users:_()(s)})))}})),(0,n.extend)(l().prototype,"notificationTypes",(function(t){t.add("postLiked",{n
//# sourceMappingURL=forum.js.map