framework/extensions/suspend/js/dist/forum.js
2019-09-20 06:22:45 +00:00

2 lines
5.7 KiB
JavaScript

module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(s,r,function(e){return t[e]}.bind(null,r));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=10)}([function(t,e){t.exports=flarum.core.compat.app},function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["components/Notification"]},function(t,e){t.exports=flarum.core.compat.Model},function(t,e){t.exports=flarum.core.compat["models/User"]},function(t,e){t.exports=flarum.core.compat["utils/UserControls"]},function(t,e){t.exports=flarum.core.compat["components/Badge"]},function(t,e){t.exports=flarum.core.compat["components/Modal"]},,function(t,e,n){"use strict";n.r(e);var s=n(1),r=n(0),a=n.n(r),o=n(6),u=n.n(o),i=n(2),p=n.n(i),l=n(7),c=n.n(l),d=n(4),f=n.n(d),h=n(5),y=n.n(h);function b(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e}var v=n(8),_=function(t){function e(){return t.apply(this,arguments)||this}b(e,t);var n=e.prototype;return n.init=function(){t.prototype.init.call(this);var e=this.props.user.suspendedUntil(),n=null;new Date>e&&(e=null),e&&(n=9999===e.getFullYear()?"indefinitely":"limited"),this.status=m.prop(n),this.daysRemaining=m.prop("limited"===n&&1-moment().diff(e,"days"))},n.className=function(){return"SuspendUserModal Modal--small"},n.title=function(){return app.translator.trans("flarum-suspend.forum.suspend_user.title",{user:this.props.user})},n.content=function(){var t=this;return m("div",{className:"Modal-body"},m("div",{className:"Form"},m("div",{className:"Form-group"},m("label",null,app.translator.trans("flarum-suspend.forum.suspend_user.status_heading")),m("div",null,m("label",{className:"checkbox"},m("input",{type:"radio",name:"status",checked:!this.status(),value:"",onclick:m.withAttr("value",this.status)}),app.translator.trans("flarum-suspend.forum.suspend_user.not_suspended_label")),m("label",{className:"checkbox"},m("input",{type:"radio",name:"status",checked:"indefinitely"===this.status(),value:"indefinitely",onclick:m.withAttr("value",this.status)}),app.translator.trans("flarum-suspend.forum.suspend_user.indefinitely_label")),m("label",{className:"checkbox SuspendUserModal-days"},m("input",{type:"radio",name:"status",checked:"limited"===this.status(),value:"limited",onclick:function(e){t.status(e.target.value),m.redraw(!0),t.$(".SuspendUserModal-days-input input").select(),m.redraw.strategy("none")}}),app.translator.trans("flarum-suspend.forum.suspend_user.limited_time_label"),"limited"===this.status()?m("div",{className:"SuspendUserModal-days-input"},m("input",{type:"number",min:"0",value:this.daysRemaining(),oninput:m.withAttr("value",this.daysRemaining),className:"FormControl"}),app.translator.trans("flarum-suspend.forum.suspend_user.limited_time_days_text")):""))),m("div",{className:"Form-group"},m(p.a,{className:"Button Button--primary",loading:this.loading,type:"submit"},app.translator.trans("flarum-suspend.forum.suspend_user.submit_button")))))},n.onsubmit=function(t){var e=this;t.preventDefault(),this.loading=!0;var n=null;switch(this.status()){case"indefinitely":n=new Date("2038-01-01");break;case"limited":n=moment().add(this.daysRemaining(),"days").toDate()}this.props.user.save({suspendedUntil:n}).then(function(){return e.hide()},this.loaded.bind(this))},e}(n.n(v).a),x=n(3),g=n.n(x),U=function(t){function e(){return t.apply(this,arguments)||this}b(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-ban"},n.href=function(){return app.route.user(this.props.notification.subject())},n.content=function(){var t=this.props.notification,e=t.content(),n=moment(e.date).from(t.createdAt(),!0);return app.translator.trans("flarum-suspend.forum.notifications.user_suspended_text",{user:t.fromUser(),timeReadable:n})},e}(g.a),S=function(t){function e(){return t.apply(this,arguments)||this}b(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-ban"},n.href=function(){return app.route.user(this.props.notification.subject())},n.content=function(){var t=this.props.notification;return app.translator.trans("flarum-suspend.forum.notifications.user_unsuspended_text",{user:t.fromUser()})},e}(g.a);a.a.initializers.add("flarum-suspend",function(){a.a.notificationComponents.userSuspended=U,a.a.notificationComponents.userUnsuspended=S,y.a.prototype.canSuspend=f.a.attribute("canSuspend"),y.a.prototype.suspendedUntil=f.a.attribute("suspendedUntil",f.a.transformDate),Object(s.extend)(u.a,"moderationControls",function(t,e){e.canSuspend()&&t.add("suspend",p.a.component({children:a.a.translator.trans("flarum-suspend.forum.user_controls.suspend_button"),icon:"fas fa-ban",onclick:function(){return a.a.modal.show(new _({user:e}))}}))}),Object(s.extend)(y.a.prototype,"badges",function(t){var e=this.suspendedUntil();new Date<e&&t.add("suspended",c.a.component({icon:"fas fa-ban",type:"suspended",label:a.a.translator.trans("flarum-suspend.forum.user_badge.suspended_tooltip")}))})})}]);
//# sourceMappingURL=forum.js.map