diff options
author | Dimitrie Hoekstra <dimitrie@gitlab.com> | 2017-03-17 17:04:51 +0000 |
---|---|---|
committer | Dimitrie Hoekstra <dimitrie@gitlab.com> | 2017-03-17 17:04:51 +0000 |
commit | b6bab6ce47813c67ea1e2c7d4fde7d9e320da99c (patch) | |
tree | 6c1b7db2aeebc5756c73842cffef22df655cc820 /app/assets/javascripts/group_name.js | |
parent | 116efdaf128ddcccc30fb82615cd964b35cacc53 (diff) | |
parent | bb1620aaf712c22c61fda098260f481ad79a05e2 (diff) | |
download | gitlab-ce-focus-mode-board.tar.gz |
Merge branch 'master' into 'focus-mode-board'focus-mode-board
# Conflicts:
# app/views/shared/issuable/_filter.html.haml
Diffstat (limited to 'app/assets/javascripts/group_name.js')
-rw-r--r-- | app/assets/javascripts/group_name.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/app/assets/javascripts/group_name.js b/app/assets/javascripts/group_name.js new file mode 100644 index 00000000000..6a028f299b1 --- /dev/null +++ b/app/assets/javascripts/group_name.js @@ -0,0 +1,40 @@ +const GROUP_LIMIT = 2; + +export default class GroupName { + constructor() { + this.titleContainer = document.querySelector('.title'); + this.groups = document.querySelectorAll('.group-path'); + this.groupTitle = document.querySelector('.group-title'); + this.toggle = null; + this.isHidden = false; + this.init(); + } + + init() { + if (this.groups.length > GROUP_LIMIT) { + this.groups[this.groups.length - 1].classList.remove('hidable'); + this.addToggle(); + } + this.render(); + } + + addToggle() { + const header = document.querySelector('.header-content'); + this.toggle = document.createElement('button'); + this.toggle.className = 'text-expander group-name-toggle'; + this.toggle.setAttribute('aria-label', 'Toggle full path'); + this.toggle.innerHTML = '...'; + this.toggle.addEventListener('click', this.toggleGroups.bind(this)); + header.insertBefore(this.toggle, this.titleContainer); + this.toggleGroups(); + } + + toggleGroups() { + this.isHidden = !this.isHidden; + this.groupTitle.classList.toggle('is-hidden'); + } + + render() { + this.titleContainer.classList.remove('initializing'); + } +} |