in static/src/javascripts/projects/common/modules/discussion/comment-box.js [465:532]
prerender() {
if (!this.options.premod) {
const premod = this.getElem('premod');
if (premod && premod.parentNode) {
premod.parentNode.removeChild(premod);
}
}
const userData = this.getUserData();
if (this.options.state === 'response') {
const submit = this.getElem('submit');
if (submit) {
submit.innerHTML = 'Post reply';
}
} else if (this.options.shouldRenderMainAvatar) {
const avatarWrapper = this.getElem('avatar-wrapper');
if (avatarWrapper) {
avatarWrapper.setAttribute('userid', userData.id);
avatarWrapper.setAttribute('data-userid', userData.id);
avatarify(avatarWrapper);
}
} else {
const container = document.getElementsByClassName(
'd-comment-box__meta'
)[0];
if (container && container.parentNode) {
container.parentNode.removeChild(container);
}
}
if (this.options.replyTo) {
const replyToAuthor = this.getElem('reply-to-author');
const parentCommentBody = this.getElem('parent-comment-body');
const parentCommentAuthor = this.getElem('parent-comment-author');
const { author, timestamp, body } = this.options.replyTo || {};
if (replyToAuthor && author) {
replyToAuthor.innerHTML = author;
}
if (parentCommentAuthor && author && timestamp) {
parentCommentAuthor.innerHTML = `${author} @ ${timestamp} said:`;
}
if (parentCommentBody && body) {
parentCommentBody.innerHTML = body;
}
const setSpoutMargin = () => {
const parentCommentSpout = this.getElem('parent-comment-spout');
const spoutOffset = replyToAuthor
? replyToAuthor.offsetLeft +
replyToAuthor.getBoundingClientRect().width / 2
: false;
if (parentCommentSpout && spoutOffset) {
parentCommentSpout.style.marginLeft = `${spoutOffset}px`;
}
};
window.setTimeout(() => setSpoutMargin(), 0);
}
}