framework/extensions/suspend/js/dist/forum.js
flarum-bot 5e81592e18 Bundled output for commit 74bcab866c
Includes transpiled JS/TS.

[skip ci]
2022-06-19 22:54:28 +00:00

2 lines
17 KiB
JavaScript
Generated

(()=>{var t={757:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,n="millisecond",s="second",r="minute",i="hour",a="day",o="week",u="month",c="quarter",l="year",d="date",f="Invalid Date",m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,p={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},v=function(t,e,n){var s=String(t);return!s||s.length>=e?t:""+Array(e+1-s.length).join(n)+t},$={s:v,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),s=Math.floor(n/60),r=n%60;return(e<=0?"+":"-")+v(s,2,"0")+":"+v(r,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var s=12*(n.year()-e.year())+(n.month()-e.month()),r=e.clone().add(s,u),i=n-r<0,a=e.clone().add(s+(i?-1:1),u);return+(-(s+(n-r)/(i?r-a:a-r))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:u,y:l,w:o,d:a,D:d,h:i,m:r,s,ms:n,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",y={};y[g]=p;var M=function(t){return t instanceof D},_=function(t,e,n){var s;if(!t)return g;if("string"==typeof t)y[t]&&(s=t),e&&(y[t]=e,s=t);else{var r=t.name;y[r]=t,s=r}return!n&&s&&(g=s),s||!n&&g},S=function(t,e){if(M(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new D(n)},b=$;b.l=_,b.i=M,b.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var D=function(){function p(t){this.$L=_(t.locale,null,!0),this.parse(t)}var v=p.prototype;return v.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var s=e.match(m);if(s){var r=s[2]-1||0,i=(s[7]||"0").substring(0,3);return n?new Date(Date.UTC(s[1],r,s[3]||1,s[4]||0,s[5]||0,s[6]||0,i)):new Date(s[1],r,s[3]||1,s[4]||0,s[5]||0,s[6]||0,i)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},v.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},v.$utils=function(){return b},v.isValid=function(){return!(this.$d.toString()===f)},v.isSame=function(t,e){var n=S(t);return this.startOf(e)<=n&&n<=this.endOf(e)},v.isAfter=function(t,e){return S(t)<this.startOf(e)},v.isBefore=function(t,e){return this.endOf(e)<S(t)},v.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},v.unix=function(){return Math.floor(this.valueOf()/1e3)},v.valueOf=function(){return this.$d.getTime()},v.startOf=function(t,e){var n=this,c=!!b.u(e)||e,f=b.p(t),m=function(t,e){var s=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return c?s:s.endOf(a)},h=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},p=this.$W,v=this.$M,$=this.$D,g="set"+(this.$u?"UTC":"");switch(f){case l:return c?m(1,0):m(31,11);case u:return c?m(1,v):m(0,v+1);case o:var y=this.$locale().weekStart||0,M=(p<y?p+7:p)-y;return m(c?$-M:$+(6-M),v);case a:case d:return h(g+"Hours",0);case i:return h(g+"Minutes",1);case r:return h(g+"Seconds",2);case s:return h(g+"Milliseconds",3);default:return this.clone()}},v.endOf=function(t){return this.startOf(t,!1)},v.$set=function(t,e){var o,c=b.p(t),f="set"+(this.$u?"UTC":""),m=(o={},o[a]=f+"Date",o[d]=f+"Date",o[u]=f+"Month",o[l]=f+"FullYear",o[i]=f+"Hours",o[r]=f+"Minutes",o[s]=f+"Seconds",o[n]=f+"Milliseconds",o)[c],h=c===a?this.$D+(e-this.$W):e;if(c===u||c===l){var p=this.clone().set(d,1);p.$d[m](h),p.init(),this.$d=p.set(d,Math.min(this.$D,p.daysInMonth())).$d}else m&&this.$d[m](h);return this.init(),this},v.set=function(t,e){return this.clone().$set(t,e)},v.get=function(t){return this[b.p(t)]()},v.add=function(n,c){var d,f=this;n=Number(n);var m=b.p(c),h=function(t){var e=S(f);return b.w(e.date(e.date()+Math.round(t*n)),f)};if(m===u)return this.set(u,this.$M+n);if(m===l)return this.set(l,this.$y+n);if(m===a)return h(1);if(m===o)return h(7);var p=(d={},d[r]=t,d[i]=e,d[s]=1e3,d)[m]||1,v=this.$d.getTime()+n*p;return b.w(v,this)},v.subtract=function(t,e){return this.add(-1*t,e)},v.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||f;var s=t||"YYYY-MM-DDTHH:mm:ssZ",r=b.z(this),i=this.$H,a=this.$m,o=this.$M,u=n.weekdays,c=n.months,l=function(t,n,r,i){return t&&(t[n]||t(e,s))||r[n].substr(0,i)},d=function(t){return b.s(i%12||12,t,"0")},m=n.meridiem||function(t,e,n){var s=t<12?"AM":"PM";return n?s.toLowerCase():s},p={YY:String(this.$y).slice(-2),YYYY:this.$y,M:o+1,MM:b.s(o+1,2,"0"),MMM:l(n.monthsShort,o,c,3),MMMM:l(c,o),D:this.$D,DD:b.s(this.$D,2,"0"),d:String(this.$W),dd:l(n.weekdaysMin,this.$W,u,2),ddd:l(n.weekdaysShort,this.$W,u,3),dddd:u[this.$W],H:String(i),HH:b.s(i,2,"0"),h:d(1),hh:d(2),a:m(i,a,!0),A:m(i,a,!1),m:String(a),mm:b.s(a,2,"0"),s:String(this.$s),ss:b.s(this.$s,2,"0"),SSS:b.s(this.$ms,3,"0"),Z:r};return s.replace(h,(function(t,e){return e||p[t]||r.replace(":","")}))},v.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},v.diff=function(n,d,f){var m,h=b.p(d),p=S(n),v=(p.utcOffset()-this.utcOffset())*t,$=this-p,g=b.m(this,p);return g=(m={},m[l]=g/12,m[u]=g,m[c]=g/3,m[o]=($-v)/6048e5,m[a]=($-v)/864e5,m[i]=$/e,m[r]=$/t,m[s]=$/1e3,m)[h]||$,f?g:b.a(g)},v.daysInMonth=function(){return this.endOf(u).$D},v.$locale=function(){return y[this.$L]},v.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),s=_(t,e,!0);return s&&(n.$L=s),n},v.clone=function(){return b.w(this.$d,this)},v.toDate=function(){return new Date(this.valueOf())},v.toJSON=function(){return this.isValid()?this.toISOString():null},v.toISOString=function(){return this.$d.toISOString()},v.toString=function(){return this.$d.toUTCString()},p}(),w=D.prototype;return S.prototype=w,[["$ms",n],["$s",s],["$m",r],["$H",i],["$W",a],["$M",u],["$y",l],["$D",d]].forEach((function(t){w[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),S.extend=function(t,e){return t.$i||(t(e,D,S),t.$i=!0),S},S.locale=_,S.isDayjs=M,S.unix=function(t){return S(1e3*t)},S.en=y[g],S.Ls=y,S.p={},S}()},221:function(t){t.exports=function(){"use strict";var t="minute",e=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(s,r,i){var a=r.prototype;i.utc=function(t){return new r({date:t,utc:!0,args:arguments})},a.utc=function(e){var n=i(this.toDate(),{locale:this.$L,utc:!0});return e?n.add(this.utcOffset(),t):n},a.local=function(){return i(this.toDate(),{locale:this.$L,utc:!1})};var o=a.parse;a.parse=function(t){t.utc&&(this.$u=!0),this.$utils().u(t.$offset)||(this.$offset=t.$offset),o.call(this,t)};var u=a.init;a.init=function(){if(this.$u){var t=this.$d;this.$y=t.getUTCFullYear(),this.$M=t.getUTCMonth(),this.$D=t.getUTCDate(),this.$W=t.getUTCDay(),this.$H=t.getUTCHours(),this.$m=t.getUTCMinutes(),this.$s=t.getUTCSeconds(),this.$ms=t.getUTCMilliseconds()}else u.call(this)};var c=a.utcOffset;a.utcOffset=function(s,r){var i=this.$utils().u;if(i(s))return this.$u?0:i(this.$offset)?c.call(this):this.$offset;if("string"==typeof s&&(s=function(t){void 0===t&&(t="");var s=t.match(e);if(!s)return null;var r=(""+s[0]).match(n)||["-",0,0],i=r[0],a=60*+r[1]+ +r[2];return 0===a?0:"+"===i?a:-a}(s),null===s))return this;var a=Math.abs(s)<=16?60*s:s,o=this;if(r)return o.$offset=a,o.$u=0===s,o;if(0!==s){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(o=this.local().add(a+u,t)).$offset=a,o.$x.$localOffset=u}else o=this.utc();return o};var l=a.format;a.format=function(t){var e=t||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,e)},a.valueOf=function(){var t=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||(new Date).getTimezoneOffset());return this.$d.valueOf()-6e4*t},a.isUTC=function(){return!!this.$u},a.toISOString=function(){return this.toDate().toISOString()},a.toString=function(){return this.toDate().toUTCString()};var d=a.toDate;a.toDate=function(t){return"s"===t&&this.$offset?i(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():d.call(this)};var f=a.diff;a.diff=function(t,e,n){if(t&&this.$u===t.$u)return f.call(this,t,e,n);var s=this.local(),r=i(t).local();return f.call(s,r,e,n)}}}()}},e={};function n(s){var r=e[s];if(void 0!==r)return r.exports;var i=e[s]={exports:{}};return t[s].call(i.exports,i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};(()=>{"use strict";n.r(s);const t=flarum.core.compat.extend,e=flarum.core.compat.app;var r=n.n(e);const i=flarum.core.compat["utils/UserControls"];var a=n.n(i);const o=flarum.core.compat["components/Button"];var u=n.n(o);const c=flarum.core.compat["components/Badge"];var l=n.n(c);const d=flarum.core.compat.Model;var f=n.n(d);const h=flarum.core.compat["models/User"];var p=n.n(h);function v(t,e){return v=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},v(t,e)}function $(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,v(t,e)}const g=flarum.core.compat["forum/app"];var y=n.n(g);const M=flarum.core.compat["components/Modal"];var _=n.n(M);const S=flarum.core.compat["utils/Stream"];var b=n.n(S);const D=flarum.core.compat["utils/withAttr"];var w=n.n(D);const O=flarum.core.compat["common/utils/ItemList"];var T=n.n(O),x=n(757),U=n.n(x),N=n(221),k=n.n(N);function C(t){return U().utc(t).isSame(U().utc("2038-01-01"))}U().extend(k());var Y=function(t){function e(){return t.apply(this,arguments)||this}$(e,t);var n=e.prototype;return n.oninit=function(e){t.prototype.oninit.call(this,e);var n=this.attrs.user.suspendedUntil(),s=this.attrs.user.suspendReason(),r=this.attrs.user.suspendMessage(),i=null;new Date>n&&(n=null),n&&(i=9999===n.getFullYear()?"indefinitely":"limited"),this.status=b()(i),this.reason=b()(s),this.message=b()(r),this.daysRemaining=b()("limited"===i&&1-dayjs().diff(n,"days"))},n.className=function(){return"SuspendUserModal Modal--medium"},n.title=function(){return y().translator.trans("flarum-suspend.forum.suspend_user.title",{user:this.attrs.user})},n.content=function(){return m("div",{className:"Modal-body"},m("div",{className:"Form"},m("div",{className:"Form-group"},m("label",null,y().translator.trans("flarum-suspend.forum.suspend_user.status_heading")),m("div",null,this.formItems().toArray())),m("div",{className:"Form-group"},m(u(),{className:"Button Button--primary",loading:this.loading,type:"submit"},y().translator.trans("flarum-suspend.forum.suspend_user.submit_button")))))},n.radioItems=function(){var t=this,e=new(T());return e.add("not-suspended",m("label",{className:"checkbox"},m("input",{type:"radio",name:"status",checked:!this.status(),value:"",onclick:w()("value",this.status)}),y().translator.trans("flarum-suspend.forum.suspend_user.not_suspended_label")),100),e.add("indefinitely",m("label",{className:"checkbox"},m("input",{type:"radio",name:"status",checked:"indefinitely"===this.status(),value:"indefinitely",onclick:w()("value",this.status)}),y().translator.trans("flarum-suspend.forum.suspend_user.indefinitely_label")),90),e.add("time-suspension",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.sync(),t.$(".SuspendUserModal-days-input input").select(),e.redraw=!1}}),y().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:w()("value",this.daysRemaining),className:"FormControl"}),y().translator.trans("flarum-suspend.forum.suspend_user.limited_time_days_text"))),80),e},n.formItems=function(){var t=new(T());return t.add("radioItems",m("div",{className:"Form-group"},this.radioItems().toArray()),100),t.add("reason",m("div",{className:"Form-group"},m("label",null,y().translator.trans("flarum-suspend.forum.suspend_user.reason"),m("textarea",{className:"FormControl",bidi:this.reason,placeholder:y().translator.trans("flarum-suspend.forum.suspend_user.placeholder_optional"),rows:"2"}))),90),t.add("message",m("div",{className:"Form-group"},m("label",null,y().translator.trans("flarum-suspend.forum.suspend_user.display_message"),m("textarea",{className:"FormControl",bidi:this.message,placeholder:y().translator.trans("flarum-suspend.forum.suspend_user.placeholder_optional"),rows:"2"}))),80),t},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=dayjs().add(this.daysRemaining(),"days").toDate()}this.attrs.user.save({suspendedUntil:n,suspendReason:this.reason(),suspendMessage:this.message()}).then((function(){return e.hide()}),this.loaded.bind(this))},e}(_());const I=flarum.core.compat["components/Notification"];var F=n.n(I),H=function(t){function e(){return t.apply(this,arguments)||this}$(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-ban"},n.href=function(){return y().route.user(this.attrs.notification.subject())},n.content=function(){var t=this.attrs.notification,e=t.content(),n=dayjs(e).from(t.createdAt(),!0);return C(e)?y().translator.trans("flarum-suspend.forum.notifications.user_suspended_indefinite_text"):y().translator.trans("flarum-suspend.forum.notifications.user_suspended_text",{timeReadable:n})},e}(F()),j=function(t){function e(){return t.apply(this,arguments)||this}$(e,t);var n=e.prototype;return n.icon=function(){return"fas fa-ban"},n.href=function(){return y().route.user(this.attrs.notification.subject())},n.content=function(){return this.attrs.notification,y().translator.trans("flarum-suspend.forum.notifications.user_unsuspended_text")},e}(F());const A=flarum.core.compat["common/components/Modal"];var L=n.n(A);const W=flarum.core.compat["common/components/Button"];var B=n.n(W);const R=flarum.core.compat["common/helpers/fullTime"];var z=n.n(R),P=function(t){function e(){return t.apply(this,arguments)||this}$(e,t);var n=e.prototype;return n.oninit=function(e){t.prototype.oninit.call(this,e),this.message=this.attrs.message,this.until=this.attrs.until},n.className=function(){return"SuspensionInfoModal Modal"},n.title=function(){return y().translator.trans("flarum-suspend.forum.suspension_info.title")},n.content=function(){var t=C(new Date(this.until))?y().translator.trans("flarum-suspend.forum.suspension_info.indefinite"):y().translator.trans("flarum-suspend.forum.suspension_info.limited",{date:z()(this.until)});return m("div",{className:"Modal-body"},m("div",{className:"Form Form--centered"},m("p",{className:"helpText"},this.message),m("p",{className:"helpText"},t),m("div",{className:"Form-group"},m(B(),{className:"Button Button--primary Button--block",onclick:this.hide.bind(this)},y().translator.trans("flarum-suspend.forum.suspension_info.dismiss_button")))))},n.hide=function(){localStorage.setItem("flarum-suspend.acknowledge-suspension",this.attrs.until.getTime()),this.attrs.state.close()},e}(L());function Z(){return setTimeout((function(){if(y().session.user){var t=y().session.user.suspendMessage(),e=y().session.user.suspendedUntil(),n=t&&e&&new Date<e,s=localStorage.getItem("flarum-suspend.acknowledge-suspension")===(null==e?void 0:e.getTime().toString());n&&!s?y().modal.show(P,{message:t,until:e}):localStorage.getItem("flarum-suspend.acknowledge-suspension")&&localStorage.removeItem("flarum-suspend.acknowledge-suspension")}}),0)}const J={"suspend/components/suspendUserModal":Y,"suspend/components/suspensionInfoModal":P,"suspend/components/UserSuspendedNotification":H,"suspend/components/UserUnsuspendedNotification":j,"suspend/checkForSuspension":Z},V=flarum.core;r().initializers.add("flarum-suspend",(function(){r().notificationComponents.userSuspended=H,r().notificationComponents.userUnsuspended=j,p().prototype.canSuspend=f().attribute("canSuspend"),p().prototype.suspendedUntil=f().attribute("suspendedUntil",f().transformDate),p().prototype.suspendReason=f().attribute("suspendReason"),p().prototype.suspendMessage=f().attribute("suspendMessage"),(0,t.extend)(a(),"moderationControls",(function(t,e){e.canSuspend()&&t.add("suspend",u().component({icon:"fas fa-ban",onclick:function(){return r().modal.show(Y,{user:e})}},r().translator.trans("flarum-suspend.forum.user_controls.suspend_button")))})),(0,t.extend)(p().prototype,"badges",(function(t){var e=this.suspendedUntil();new Date<e&&t.add("suspended",l().component({icon:"fas fa-ban",type:"suspended",label:r().translator.trans("flarum-suspend.forum.user_badge.suspended_tooltip")}))})),Z()})),Object.assign(V.compat,J)})(),module.exports=s})();
//# sourceMappingURL=forum.js.map