Welcome to mirror list, hosted at ThFree Co, Russian Federation.

highlight_current_user.js « markdown « behaviors « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0fac278573e4aea97ace235b11cf03078121a223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Highlights the current user in existing elements with a user ID data attribute.
 *
 * @param elements DOM elements that represent user mentions
 */
export default function highlightCurrentUser(elements) {
  const currentUserId = gon && gon.current_user_id;
  if (!currentUserId) {
    return;
  }

  elements.forEach((element) => {
    if (parseInt(element.dataset.user, 10) === currentUserId) {
      element.classList.add('current-user');
    }
  });
}