framework/extensions/nicknames/js/dist/forum.js

2 lines
4.9 KiB
JavaScript
Raw Normal View History

(()=>{var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var a in n)t.o(n,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{extend:()=>M});const n=flarum.core.compat["forum/app"];var a=t.n(n);const r=flarum.core.compat["common/extend"],o=flarum.core.compat["common/components/Button"];var i=t.n(o);const s=flarum.core.compat["common/components/EditUserModal"];var c=t.n(s);const u=flarum.core.compat["forum/components/SignUpModal"];var l=t.n(u);const d=flarum.core.compat["forum/components/SettingsPage"];var p=t.n(d);const f=flarum.core.compat["common/utils/extractText"];var k=t.n(f);const h=flarum.core.compat["common/utils/Stream"];var y=t.n(h);function b(t,e){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},b(t,e)}const v=flarum.core.compat["common/components/Modal"];var g=function(t){var e,n;function r(){return t.apply(this,arguments)||this}n=t,(e=r).prototype=Object.create(n.prototype),e.prototype.constructor=e,b(e,n);var o=r.prototype;return o.oninit=function(e){t.prototype.oninit.call(this,e),this.nickname=y()(a().session.user.displayName())},o.className=function(){return"NickameModal Modal--small"},o.title=function(){return a().translator.trans("flarum-nicknames.forum.change_nickname.title")},o.content=function(){return m("div",{className:"Modal-body"},m("div",{className:"Form Form--centered"},m("div",{className:"Form-group"},m("input",{type:"text",autocomplete:"off",name:"nickname",className:"FormControl",bidi:this.nickname,disabled:this.loading})),m("div",{className:"Form-group"},i().component({className:"Button Button--primary Button--block",type:"submit",loading:this.loading},a().translator.trans("flarum-nicknames.forum.change_nickname.submit_button")))))},o.onsubmit=function(t){var e=this;t.preventDefault(),this.nickname()!==a().session.user.displayName()?(this.loading=!0,a().session.user.save({nickname:this.nickname()},{errorHandler:this.onerror.bind(this)}).then(this.hide.bind(this)).catch((function(){e.loading=!1,m.redraw()}))):this.hide()},r}(t.n(v)());const N=flarum.core.compat["common/extenders"];var _=t.n(N);const x=flarum.core.compat["common/models/User"];var O=t.n(x);const M=[new(_().Model)(O()).attribute("canEditNickname")];a().initializers.add("flarum/nicknames",(function(){(0,r.extend)(p().prototype,"accountItems",(function(t){"nickname"===a().forum.attribute("displayNameDriver")&&this.user.canEditNickname()&&t.add("changeNickname",m(i(),{className:"Button",onclick:function(){return a().modal.show(g)}},a().translator.trans("flarum-nicknames.forum.settings.change_nickname_button")))})),(0,r.extend)(c().prototype,"oninit",(function(){this.nickname=y()(this.attrs.user.displayName())})),(0,r.extend)(c().prototype,"fields",(function(t){"nickname"===a().forum.attribute("displayNameDriver")&&this.attrs.user.canEditNickname()&&t.add("nickname",m("div",{className:"Form-group"},m("label",null,a().translator.trans("flarum-nicknames.forum.edit_user.nicknames_heading")),m("input",{className:"FormControl",placeholder:k()(a().translator.trans("flarum-nicknames.forum.edit_user.nicknames_text")),bidi:this.nickname})),100)})),(0,r.extend)(c().prototype,"data",(function(t){"nickname"===a().forum.attribute("displayNameDriver")&&this.attrs.user.canEditNickname()&&this.nickname()!==this.attrs.user.displayName()&&(t.nickname=this.nickname())})),(0,r.extend)(l().prototype,"oninit",(function(){"nickname"===a().forum.attribute("displayNameDriver")&&(this.nickname=y()(this.attrs.username||""))})),(0,r.extend)(l().prototype,"onready",(function(){"nickname"===a().forum.attribute("displayNameDriver")&&a().forum.attribute("setNicknameOnRegistration")&&a().forum.attribute("randomizeUsernameOnRegistration")&&this.$("[name=nickname]").select()})),(0,r.extend)(l().prototype,"fiel
//# sourceMappingURL=forum.js.map