framework/extensions/flags/js/dist/forum.js
flarum-bot 3942ec4e00 Bundled output for commit 1bd32bb4e0
Includes transpiled JS/TS.

[skip ci]
2022-01-07 14:06:45 +00:00

2 lines
13 KiB
JavaScript

module.exports=function(t){var a={};function o(e){if(a[e])return a[e].exports;var n=a[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=t,o.c=a,o.d=function(t,a,e){o.o(t,a)||Object.defineProperty(t,a,{enumerable:!0,get:e})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(t,a){if(1&a&&(t=o(t)),8&a)return t;if(4&a&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(o.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&a&&"string"!=typeof t)for(var n in t)o.d(e,n,function(a){return t[a]}.bind(null,n));return e},o.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(a,"a",a),a},o.o=function(t,a){return Object.prototype.hasOwnProperty.call(t,a)},o.p="",o(o.s=25)}([function(t,a){t.exports=flarum.core.compat.app},function(t,a){t.exports=flarum.core.compat["forum/app"]},function(t,a){t.exports=flarum.core.compat.Model},function(t,a){t.exports=flarum.core.compat["common/utils/withAttr"]},function(t,a){t.exports=flarum.core.compat.extend},function(t,a){t.exports=flarum.core.compat["components/Post"]},function(t,a){t.exports=flarum.core.compat["utils/PostControls"]},function(t,a){t.exports=flarum.core.compat["components/Button"]},function(t,a){t.exports=flarum.core.compat["common/components/Button"]},function(t,a){t.exports=flarum.core.compat["common/utils/Stream"]},function(t,a){t.exports=flarum.core.compat["components/Page"]},function(t,a){t.exports=flarum.core.compat.Component},function(t,a){t.exports=flarum.core.compat["components/Link"]},function(t,a){t.exports=flarum.core.compat["components/LoadingIndicator"]},function(t,a){t.exports=flarum.core.compat["helpers/avatar"]},function(t,a){t.exports=flarum.core.compat["helpers/username"]},function(t,a){t.exports=flarum.core.compat["helpers/icon"]},function(t,a){t.exports=flarum.core.compat["helpers/humanTime"]},function(t,a){t.exports=flarum.core.compat["common/components/Modal"]},function(t,a){t.exports=flarum.core.compat["common/utils/ItemList"]},function(t,a){t.exports=flarum.core.compat["components/HeaderSecondary"]},function(t,a){t.exports=flarum.core.compat["components/NotificationsDropdown"]},function(t,a){t.exports=flarum.core.compat["utils/ItemList"]},function(t,a){t.exports=flarum.core.compat["utils/humanTime"]},function(t,a){t.exports=flarum.core},function(t,a,o){"use strict";o.r(a);var e=o(0),n=o.n(e),s=o(2),r=o.n(s);function l(t,a){return(l=Object.setPrototypeOf||function(t,a){return t.__proto__=a,t})(t,a)}function i(t,a){t.prototype=Object.create(a.prototype),t.prototype.constructor=t,l(t,a)}var c=function(t){function a(){return t.apply(this,arguments)||this}return i(a,t),a}(r.a);Object.assign(c.prototype,{type:r.a.attribute("type"),reason:r.a.attribute("reason"),reasonDetail:r.a.attribute("reasonDetail"),createdAt:r.a.attribute("createdAt",r.a.transformDate),post:r.a.hasOne("post"),user:r.a.hasOne("user")});var u=c,f=o(10),p=o.n(f),d=o(11),g=o.n(d),h=o(12),b=o.n(h),v=o(13),_=o.n(v),y=o(14),x=o.n(y),N=o(15),F=o.n(N),k=o(16),w=o.n(k),C=o(17),D=o.n(C),P=function(t){function a(){return t.apply(this,arguments)||this}i(a,t);var o=a.prototype;return o.oninit=function(a){t.prototype.oninit.call(this,a),this.state=this.attrs.state},o.view=function(){var t=this.state.cache||[];return m("div",{className:"NotificationList FlagList"},m("div",{className:"NotificationList-header"},m("h4",{className:"App-titleControl App-titleControl--text"},app.translator.trans("flarum-flags.forum.flagged_posts.title"))),m("div",{className:"NotificationList-content"},m("ul",{className:"NotificationGroup-content"},t.length?t.map((function(t){var a=t.post();return m("li",null,m(b.a,{href:app.route.post(a),className:"Notification Flag",onclick:function(t){app.flags.index=a,t.redraw=!1}},x()(a.user()),w()("fas fa-flag",{className:"Notification-icon"}),m("span",{className:"Notification-content"},app.translator.trans("flarum-flags.forum.flagged_posts.item_text",{username:F()(a.user()),em:m("em",null),discussion:a.discussion().title()})),D()(t.createdAt()),m("div",{className:"Notification-excerpt"},a.contentPlain())))})):this.state.loading?_.a.component({className:"LoadingIndicator--block"}):m("div",{className:"NotificationList-empty"},app.translator.trans("flarum-flags.forum.flagged_posts.empty_text")))))},a}(g.a),O=function(t){function a(){return t.apply(this,arguments)||this}i(a,t);var o=a.prototype;return o.oninit=function(a){t.prototype.oninit.call(this,a),app.history.push("flags"),app.flags.load(),this.bodyClass="App--flags"},o.view=function(){return m("div",{className:"FlagsPage"},m(P,{state:app.flags}))},a}(p.a),A=function(){function t(t){this.app=t,this.loading=!1}return t.prototype.load=function(){var t=this;this.cache&&!this.app.session.user.attribute("newFlagCount")||(this.loading=!0,m.redraw(),this.app.store.find("flags").then((function(a){t.app.session.user.pushAttributes({newFlagCount:0}),t.cache=a.sort((function(t,a){return a.createdAt()-t.createdAt()}))})).catch((function(){})).then((function(){t.loading=!1,m.redraw()})))},t}(),j=o(4),M=o(6),L=o.n(M),B=o(7),T=o.n(B),S=o(1),I=o.n(S),R=o(18),E=o.n(R),H=o(8),U=o.n(H),G=o(9),q=o.n(G),z=o(3),V=o.n(z),J=o(19),K=o.n(J),Q=function(t){function a(){return t.apply(this,arguments)||this}i(a,t);var o=a.prototype;return o.oninit=function(a){t.prototype.oninit.call(this,a),this.success=!1,this.reason=q()(""),this.reasonDetail=q()("")},o.className=function(){return"FlagPostModal Modal--medium"},o.title=function(){return I.a.translator.trans("flarum-flags.forum.flag_post.title")},o.content=function(){return this.success?m("div",{className:"Modal-body"},m("div",{className:"Form Form--centered"},m("p",{className:"helpText"},I.a.translator.trans("flarum-flags.forum.flag_post.confirmation_message")),m("div",{className:"Form-group"},m(U.a,{className:"Button Button--primary Button--block",onclick:this.hide.bind(this)},I.a.translator.trans("flarum-flags.forum.flag_post.dismiss_button"))))):m("div",{className:"Modal-body"},m("div",{className:"Form Form--centered"},m("div",{className:"Form-group"},m("div",null,this.flagReasons().toArray())),m("div",{className:"Form-group"},m(U.a,{className:"Button Button--primary Button--block",type:"submit",loading:this.loading,disabled:!this.reason()},I.a.translator.trans("flarum-flags.forum.flag_post.submit_button")))))},o.flagReasons=function(){var t=new K.a,a=I.a.forum.attribute("guidelinesUrl");return t.add("off-topic",m("label",{className:"checkbox"},m("input",{type:"radio",name:"reason",checked:"off_topic"===this.reason(),value:"off_topic",onclick:V()("value",this.reason)}),m("strong",null,I.a.translator.trans("flarum-flags.forum.flag_post.reason_off_topic_label")),I.a.translator.trans("flarum-flags.forum.flag_post.reason_off_topic_text"),"off_topic"===this.reason()?m("textarea",{className:"FormControl",placeholder:I.a.translator.trans("flarum-flags.forum.flag_post.reason_details_placeholder"),value:this.reasonDetail(),oninput:V()("value",this.reasonDetail)}):""),70),t.add("inappropriate",m("label",{className:"checkbox"},m("input",{type:"radio",name:"reason",checked:"inappropriate"===this.reason(),value:"inappropriate",onclick:V()("value",this.reason)}),m("strong",null,I.a.translator.trans("flarum-flags.forum.flag_post.reason_inappropriate_label")),I.a.translator.trans("flarum-flags.forum.flag_post.reason_inappropriate_text",{a:a?m("a",{href:a,target:"_blank"}):void 0}),"inappropriate"===this.reason()?m("textarea",{className:"FormControl",placeholder:I.a.translator.trans("flarum-flags.forum.flag_post.reason_details_placeholder"),value:this.reasonDetail(),oninput:V()("value",this.reasonDetail)}):""),60),t.add("spam",m("label",{className:"checkbox"},m("input",{type:"radio",name:"reason",checked:"spam"===this.reason(),value:"spam",onclick:V()("value",this.reason)}),m("strong",null,I.a.translator.trans("flarum-flags.forum.flag_post.reason_spam_label")),I.a.translator.trans("flarum-flags.forum.flag_post.reason_spam_text"),"spam"===this.reason()?m("textarea",{className:"FormControl",placeholder:I.a.translator.trans("flarum-flags.forum.flag_post.reason_details_placeholder"),value:this.reasonDetail(),oninput:V()("value",this.reasonDetail)}):""),50),t.add("other",m("label",{className:"checkbox"},m("input",{type:"radio",name:"reason",checked:"other"===this.reason(),value:"other",onclick:V()("value",this.reason)}),m("strong",null,I.a.translator.trans("flarum-flags.forum.flag_post.reason_other_label")),"other"===this.reason()?m("textarea",{className:"FormControl",value:this.reasonDetail(),oninput:V()("value",this.reasonDetail)}):""),10),t},o.onsubmit=function(t){var a=this;t.preventDefault(),this.loading=!0,I.a.store.createRecord("flags").save({reason:"other"===this.reason()?null:this.reason(),reasonDetail:this.reasonDetail(),relationships:{user:I.a.session.user,post:this.attrs.post}},{errorHandler:this.onerror.bind(this)}).then((function(){return a.success=!0})).catch((function(){})).then(this.loaded.bind(this))},a}(E.a),W=function(){Object(j.extend)(L.a,"userControls",(function(t,a){!a.isHidden()&&"comment"===a.contentType()&&a.canFlag()&&t.add("flag",m(T.a,{icon:"fas fa-flag",onclick:function(){return n.a.modal.show(Q,{post:a})}},n.a.translator.trans("flarum-flags.forum.post_controls.flag_button")))}))},X=o(20),Y=o.n(X),Z=o(21),$=function(t){function a(){return t.apply(this,arguments)||this}i(a,t),a.initAttrs=function(a){a.label=a.label||app.translator.trans("flarum-flags.forum.flagged_posts.tooltip"),a.icon=a.icon||"fas fa-flag",t.initAttrs.call(this,a)};var o=a.prototype;return o.getMenu=function(){return m("div",{className:"Dropdown-menu "+this.attrs.menuClassName,onclick:this.menuClick.bind(this)},this.showing?P.component({state:this.attrs.state}):"")},o.goToRoute=function(){m.route.set(app.route("flags"))},o.getUnreadCount=function(){return app.flags.cache?app.flags.cache.length:app.forum.attribute("flagCount")},o.getNewCount=function(){return app.session.user.attribute("newFlagCount")},a}(o.n(Z).a),tt=function(){Object(j.extend)(Y.a.prototype,"items",(function(t){n.a.forum.attribute("canViewFlags")&&t.add("flags",m($,{state:n.a.flags}),15)}))},at=o(5),ot=o.n(at),et=o(22),nt=o.n(et),st=o(23),rt=o.n(st),lt=function(){Object(j.extend)(ot.a.prototype,"elementAttrs",(function(t){this.attrs.post.flags().length&&(t.className+=" Post--flagged")})),ot.a.prototype.dismissFlag=function(t){var a=this.attrs.post;return delete a.data.relationships.flags,this.subtree.invalidate(),n.a.flags.cache&&n.a.flags.cache.some((function(t,o){if(t.post()===a){if(n.a.flags.cache.splice(o,1),n.a.flags.index===a){var e=n.a.flags.cache[o];if(e||(e=n.a.flags.cache[0]),e){var s=e.post();n.a.flags.index=s,m.route.set(n.a.route.post(s))}}return!0}})),n.a.request({url:n.a.forum.attribute("apiUrl")+a.apiEndpoint()+"/flags",method:"DELETE",body:t})},ot.a.prototype.flagActionItems=function(){var t=this,a=new nt.a,o=L.a.destructiveControls(this.attrs.post);return Object.keys(o.items).forEach((function(a){var e=o.get(a).attrs;e.className="Button",Object(j.extend)(e,"onclick",(function(){return t.dismissFlag()}))})),a.add("controls",m("div",{className:"ButtonGroup"},o.toArray())),a.add("dismiss",m(T.a,{className:"Button",icon:"far fa-eye-slash",onclick:this.dismissFlag.bind(this)},n.a.translator.trans("flarum-flags.forum.post.dismiss_flag_button")),-100),a},Object(j.extend)(ot.a.prototype,"content",(function(t){var a=this,o=this.attrs.post,e=o.flags();e.length&&(o.isHidden()&&(this.revealContent=!0),t.unshift(m("div",{className:"Post-flagged"},m("div",{className:"Post-flagged-flags"},e.map((function(t){return m("div",{className:"Post-flagged-flag"},a.flagReason(t))}))),m("div",{className:"Post-flagged-actions"},this.flagActionItems().toArray()))))})),ot.a.prototype.flagReason=function(t){if("user"===t.type()){var a=t.user(),o=t.reason()?n.a.translator.trans("flarum-flags.forum.flag_post.reason_"+t.reason()+"_label"):null,e=t.reasonDetail(),s=rt()(t.createdAt());return[n.a.translator.trans(o?"flarum-flags.forum.post.flagged_by_with_reason_text":"flarum-flags.forum.post.flagged_by_text",{time:s,user:a,reason:o}),e?m("span",{className:"Post-flagged-detail"},e):""]}}},it={"flags/addFlagsToPosts":lt,"flags/addFlagControl":W,"flags/addFlagsDropdown":tt,"flags/models/Flag":u,"flags/components/FlagList":P,"flags/components/FlagPostModal":Q,"flags/components/FlagsPage":O,"flags/components/FlagsDropdown":$},ct=o(24);n.a.initializers.add("flarum-flags",(function(){n.a.store.models.posts.prototype.flags=r.a.hasMany("flags"),n.a.store.models.posts.prototype.canFlag=r.a.attribute("canFlag"),n.a.store.models.flags=u,n.a.routes.flags={path:"/flags",component:O},n.a.flags=new A(n.a),W(),tt(),lt()})),Object.assign(ct.compat,it)}]);
//# sourceMappingURL=forum.js.map