mirror of
https://github.com/flarum/framework.git
synced 2025-01-25 16:29:30 +08:00
3757bde4fc
Includes transpiled JS/TS, and Typescript declaration files (typings). [skip ci]
2 lines
4.5 KiB
JavaScript
Generated
2 lines
4.5 KiB
JavaScript
Generated
(()=>{var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};(()=>{"use strict";e.r(t),e.d(t,{extend:()=>M});const n=flarum.core.compat["forum/app"];var a=e.n(n);const r=flarum.core.compat["common/extend"],i=flarum.core.compat["common/components/Button"];var o=e.n(i);const s=flarum.core.compat["common/components/EditUserModal"];var c=e.n(s);const u=flarum.core.compat["forum/components/SignUpModal"];var l=e.n(u);const d=flarum.core.compat["forum/components/SettingsPage"];var p=e.n(d);const f=flarum.core.compat["common/utils/extractText"];var k=e.n(f);const h=flarum.core.compat["common/utils/Stream"];var b=e.n(h);const y=flarum.core.compat["common/components/Modal"];var g=e.n(y);class v extends(g()){oninit(e){super.oninit(e),this.nickname=b()(a().session.user.displayName())}className(){return"NickameModal Modal--small"}title(){return a().translator.trans("flarum-nicknames.forum.change_nickname.title")}content(){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"},m(o(),{className:"Button Button--primary Button--block",type:"submit",loading:this.loading},a().translator.trans("flarum-nicknames.forum.change_nickname.submit_button")))))}onsubmit(e){e.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((()=>{this.loading=!1,m.redraw()}))):this.hide()}}const N=flarum.core.compat["common/extenders"];var x=e.n(N);const _=flarum.core.compat["common/models/User"];var O=e.n(_);const M=[new(x().Model)(O()).attribute("canEditNickname")];a().initializers.add("flarum/nicknames",(()=>{(0,r.extend)(p().prototype,"accountItems",(function(e){"nickname"===a().forum.attribute("displayNameDriver")&&this.user.canEditNickname()&&e.add("changeNickname",m(o(),{className:"Button",onclick:()=>a().modal.show(v)},a().translator.trans("flarum-nicknames.forum.settings.change_nickname_button")))})),(0,r.extend)(c().prototype,"oninit",(function(){this.nickname=b()(this.attrs.user.displayName())})),(0,r.extend)(c().prototype,"fields",(function(e){"nickname"===a().forum.attribute("displayNameDriver")&&this.attrs.user.canEditNickname()&&e.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(e){"nickname"===a().forum.attribute("displayNameDriver")&&this.attrs.user.canEditNickname()&&this.nickname()!==this.attrs.user.displayName()&&(e.nickname=this.nickname())})),(0,r.extend)(l().prototype,"oninit",(function(){"nickname"===a().forum.attribute("displayNameDriver")&&(this.nickname=b()(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,"fields",(function(e){"nickname"===a().forum.attribute("displayNameDriver")&&a().forum.attribute("setNicknameOnRegistration")&&(e.add("nickname",m("div",{className:"Form-group"},m("input",{className:"FormControl",name:"nickname",type:"text",placeholder:k()(a().translator.trans("flarum-nicknames.forum.sign_up.nickname_placeholder")),bidi:this.nickname,disabled:this.loading||this.isProvided("nickname"),required:a().forum.attribute("randomizeUsernameOnRegistration")})),25),a().forum.attribute("randomizeUsernameOnRegistration")&&e.remove("username"))})),(0,r.extend)(l().prototype,"submitData",(function(e){if("nickname"===a().forum.attribute("displayNameDriver")&&a().forum.attribute("setNicknameOnRegistration")&&(e.nickname=this.nickname(),a().forum.attribute("randomizeUsernameOnRegistration"))){const t=new Uint32Array(2);crypto.getRandomValues(t),e.username=t.join("")}}))}))})(),module.exports=t})();
|
|
//# sourceMappingURL=forum.js.map
|