framework/extensions/likes/js/dist/forum.js
flarum-bot 707ca2d16d Bundled output for commit 3246f5a8f6
Includes transpiled JS/TS.

[skip ci]
2022-07-14 13:48:19 +00:00

2 lines
4.9 KiB
JavaScript
Generated

(()=>{var t={n:o=>{var e=o&&o.__esModule?()=>o.default:()=>o;return t.d(e,{a:e}),e},d:(o,e)=>{for(var n in e)t.o(e,n)&&!t.o(o,n)&&Object.defineProperty(o,n,{enumerable:!0,get:e[n]})},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 e=flarum.core.compat["common/extend"],n=flarum.core.compat["forum/app"];var r=t.n(n);const s=flarum.core.compat["common/models/Post"];var a=t.n(s);const i=flarum.core.compat["common/Model"];var u=t.n(i);const c=flarum.core.compat["forum/components/NotificationGrid"];var l=t.n(c);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 x(t,o){return x=Object.setPrototypeOf||function(t,o){return t.__proto__=o,t},x(t,o)}function M(t,o){t.prototype=Object.create(o.prototype),t.prototype.constructor=t,x(t,o)}const j=flarum.core.compat["common/components/Modal"];var O=t.n(j);const N=flarum.core.compat["common/helpers/avatar"];var B=t.n(N),S=function(t){function o(){return t.apply(this,arguments)||this}M(o,t);var e=o.prototype;return e.className=function(){return"PostLikesModal Modal--small"},e.title=function(){return r().translator.trans("flarum-likes.forum.post_likes.title")},e.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)},B()(t)," ",g()(t)))}))))},o}(O());const I=flarum.core.compat["forum/components/Notification"];var T=t.n(I);const U=flarum.core.compat["common/utils/string"];var w=function(t){function o(){return t.apply(this,arguments)||this}M(o,t);var e=o.prototype;return e.icon=function(){return"far fa-thumbs-up"},e.href=function(){return r().route.post(this.attrs.notification.subject())},e.content=function(){var t=this.attrs.notification.fromUser();return r().translator.trans("flarum-likes.forum.notifications.post_liked_text",{user:t,count:1})},e.excerpt=function(){return(0,U.truncate)(this.attrs.notification.subject().contentPlain(),200)},o}(T());const C=flarum.core.compat["forum/components/UserPage"];var z=t.n(C);const A=flarum.core.compat["common/components/LinkButton"];var D=t.n(A);const G=flarum.core.compat["forum/components/PostsUserPage"];var H=function(t){function o(){return t.apply(this,arguments)||this}return M(o,t),o.prototype.loadResults=function(t){return r().store.find("posts",{filter:{type:"comment",likedBy:this.user.id()},page:{offset:t,limit:this.loadLimit},sort:"-createdAt"})},o}(t.n(G)());r().initializers.add("flarum-likes",(function(){r().notificationComponents.postLiked=w,a().prototype.canLike=u().attribute("canLike"),a().prototype.likes=u().hasMany("likes"),(0,e.extend)(k().prototype,"actionItems",(function(t){var o=this.attrs.post;if(!o.isHidden()&&o.canLike()){var e=o.likes(),n=r().session.user&&e&&e.some((function(t){return t===r().session.user}));t.add("like",p().component({className:"Button Button--link",onclick:function(){n=!n,o.save({isLiked:n});var t=o.data.relationships.likes.data;t.some((function(o,e){if(o.id===r().session.user.id())return t.splice(e,1),!0})),n&&t.unshift({type:"users",id:r().session.user.id()})}},r().translator.trans(n?"flarum-likes.forum.post.unlike_link":"flarum-likes.forum.post.like_link")))}})),(0,e.extend)(k().prototype,"footerItems",(function(t){var o=this.attrs.post,e=o.likes();if(e&&e.length){var n=e.length>4,s=e.sort((function(t){return t===r().session.user?-1:1})).slice(0,n?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(n){var a=e.length-s.length;s.push(m("a",{href:"#",onclick:function(t){t.preventDefault(),r().modal.show(S,{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"+(e[0]===r().session.user?"_self":"")+"_text",{count:s.length,users:_()(s)})))}})),r().routes["user.likes"]={path:"/u/:username/likes",component:H},(0,e.extend)(z().prototype,"navItems",(function(t){var o=this.user;t.add("likes",m(D(),{href:r().route("user.likes",{username:o.slug()}),icon:"far fa-thumbs-up"},r().translator.trans("flarum-likes.forum.user.likes_link")),88)})),(0,e.extend)(l().prototype,"notificationTypes",(function(t){t.add("postLiked",{name:"postLiked",icon:"far fa-thumbs-up",label:r().translator.trans("flarum-likes.forum.settings.notify_post_liked_label")})}))}))})(),module.exports=o})();
//# sourceMappingURL=forum.js.map