2017-10-07 00:25:17 -04:00
|
|
|
export function setPositionDataAttribute(el, options) {
|
|
|
|
// Update position data attribute so that the
|
|
|
|
// new comment form can use this data for ajax request
|
|
|
|
const { x, y, width, height } = options;
|
2018-06-16 17:50:13 -04:00
|
|
|
const { position } = el.dataset;
|
|
|
|
|
2020-05-07 17:09:26 -04:00
|
|
|
const positionObject = { ...JSON.parse(position), x, y, width, height };
|
2017-10-07 00:25:17 -04:00
|
|
|
|
2022-06-17 11:08:29 -04:00
|
|
|
el.dataset.position = JSON.stringify(positionObject);
|
2017-10-07 00:25:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function updateDiscussionAvatarBadgeNumber(discussionEl, newBadgeNumber) {
|
2022-02-03 07:18:57 -05:00
|
|
|
const avatarBadgeEl = discussionEl.querySelector('.image-diff-avatar-link .design-note-pin');
|
2020-05-11 05:09:45 -04:00
|
|
|
avatarBadgeEl.textContent = newBadgeNumber;
|
2017-10-07 00:25:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function updateDiscussionBadgeNumber(discussionEl, newBadgeNumber) {
|
2022-02-03 07:18:57 -05:00
|
|
|
const discussionBadgeEl = discussionEl.querySelector('.design-note-pin');
|
2020-05-11 05:09:45 -04:00
|
|
|
discussionBadgeEl.textContent = newBadgeNumber;
|
2017-10-07 00:25:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export function toggleCollapsed(event) {
|
|
|
|
const toggleButtonEl = event.currentTarget;
|
|
|
|
const discussionNotesEl = toggleButtonEl.closest('.discussion-notes');
|
|
|
|
const formEl = discussionNotesEl.querySelector('.discussion-form');
|
|
|
|
const isCollapsed = discussionNotesEl.classList.contains('collapsed');
|
|
|
|
|
|
|
|
if (isCollapsed) {
|
|
|
|
discussionNotesEl.classList.remove('collapsed');
|
|
|
|
} else {
|
|
|
|
discussionNotesEl.classList.add('collapsed');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Override the inline display style set in notes.js
|
|
|
|
if (formEl && !isCollapsed) {
|
|
|
|
formEl.style.display = 'none';
|
|
|
|
} else if (formEl && isCollapsed) {
|
|
|
|
formEl.style.display = 'block';
|
|
|
|
}
|
|
|
|
}
|