status-bar-manager.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. module.exports = class StatusBarManager {
  2. constructor () {
  3. this.span = document.createElement('span')
  4. this.element = document.createElement('div')
  5. this.element.id = 'status-bar-auto-highlight'
  6. this.element.className = 'block'
  7. this.element.appendChild(this.span)
  8. this.container = document.createElement('div')
  9. this.container.className = 'inline-block'
  10. this.container.appendChild(this.element)
  11. }
  12. initialize (statusBarService) {
  13. this.statusBarService = statusBarService
  14. }
  15. update (count) {
  16. this.span.className = atom.config.get('auto-highlight.countDisplayStyles')
  17. this.span.textContent = count
  18. this.element.style.display = 'inline-block'
  19. }
  20. clear () {
  21. this.element.style.display = 'none'
  22. }
  23. attach () {
  24. const displayPosition = atom.config.get('auto-highlight.countDisplayPosition')
  25. this.tile = this.statusBarService[`add${displayPosition}Tile`]({
  26. item: this.container,
  27. priority: atom.config.get('auto-highlight.countDisplayPriority')
  28. })
  29. }
  30. detach () {
  31. if (this.tile) this.tile.destroy()
  32. }
  33. }