2018-03-17 18:26:18 +05:30
|
|
|
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-11-08 19:23:39 +05:30
|
|
|
const { position } = el.dataset;
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
const positionObject = { ...JSON.parse(position), x, y, width, height };
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
el.setAttribute('data-position', JSON.stringify(positionObject));
|
|
|
|
}
|
|
|
|
|
|
|
|
export function updateDiscussionAvatarBadgeNumber(discussionEl, newBadgeNumber) {
|
2022-04-04 11:22:00 +05:30
|
|
|
const avatarBadgeEl = discussionEl.querySelector('.image-diff-avatar-link .design-note-pin');
|
2020-05-24 23:13:21 +05:30
|
|
|
avatarBadgeEl.textContent = newBadgeNumber;
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export function updateDiscussionBadgeNumber(discussionEl, newBadgeNumber) {
|
2022-04-04 11:22:00 +05:30
|
|
|
const discussionBadgeEl = discussionEl.querySelector('.design-note-pin');
|
2020-05-24 23:13:21 +05:30
|
|
|
discussionBadgeEl.textContent = newBadgeNumber;
|
2018-03-17 18:26:18 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
}
|