2 div(:id="'player_' + uid")
4 :id="'modalBio_' + uid"
9 :data-checkbox="'modalBio_' + uid"
12 div(v-if="st.user.id == uid")
14 button(@click="toggleEdit()")
15 | {{ st.tr[modeEdit ? "Cancel" : "Edit"] }}
21 fieldset(v-if="userBio !== undefined && modeEdit")
23 @input="adjustHeight()"
28 v-if="userBio !== undefined"
29 v-html="parseHtml(userBio)"
30 @click="modeEdit = !modeEdit"
32 .dialog.text-center {{ st.tr[infoMsg] }}
34 :class="{ clickable: !!uname }"
37 | {{ uname || "@nonymous" }}
41 import { store } from "@/store";
42 import { ajax } from "@/utils/ajax";
43 import { processModalClick } from "@/utils/modalClick.js";
46 props: ["uid", "uname"],
56 parseHtml: function(txt) {
57 return !txt.match(/<[/a-zA-Z]+>/)
60 txt.replace(/\n\n/g, "<br/><div class='br'></div>")
61 .replace(/\n/g, "<br/>")
64 adjustHeight: function() {
65 // https://stackoverflow.com/a/48460773
66 let t = document.querySelector("#player_" + this.uid + " textarea");
68 t.style.height = (t.scrollHeight + 3) + "px";
70 toggleEdit: function() {
71 this.modeEdit = !this.modeEdit;
72 if (this.modeEdit) this.$nextTick(this.adjustHeight);
76 // Anonymous users have no bio:
79 document.querySelector("#modalBio_" + this.uid).checked = true;
80 if (this.userBio === undefined) {
85 data: { id: this.uid },
87 this.userBio = res.bio;
91 document.querySelector("#player_" + this.uid + " > .bio-div")
92 .addEventListener("click", processModalClick);
94 else if (this.modeEdit) this.adjustHeight();
97 this.modeEdit = false;
102 data: { bio: this.userBio },
104 this.infoMsg = "Modifications applied!";
114 // bio-content HTML elements are added after initial rendering
117 margin: 0 var(--universal-margin)
119 margin: var(--universal-margin) 0
125 <style lang="sass" scoped>
126 [type="checkbox"].modal+div .card
141 margin: 0 var(--universal-margin)
142 width: calc(100% - 2 * var(--universal-margin))